stm32-eth 0.8.2

Embedded Rust Ethernet driver for the STM32 MCU series
Documentation
name: Build
on:
  pull_request:
  push:
    branches:
      - master
      - staging
      - trying

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-D warnings"

jobs:
  style:
    name: style
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: cargo fmt --check
        run: cargo fmt --all --check

  # Run cargo test
  test:
    name: test
    strategy:
      matrix:
        target:
          - x86_64-unknown-linux-gnu
        toolchain:
          - stable
        features:
          - stm32f745,ptp
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
        run: |
          rustup set profile minimal
          rustup override set ${{ matrix.toolchain }}
          rustup target add ${{ matrix.target }}

      - name: cargo test the documentation and readme
        run: |
          cargo test --target=${{ matrix.target }} --no-default-features --features ${{ matrix.features }}

  # Compilation
  build:
    name: build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          - x86_64-unknown-linux-gnu
        toolchain:
          - stable
        features:
          - stm32f107
          - stm32f407
          - stm32f417
          - stm32f427
          - stm32f437
          - stm32f439
          - stm32f469
          - stm32f479
          - stm32f429
          - stm32f745
          - stm32f746
          - stm32f756
          - stm32f765
          - stm32f767
          - stm32f769
          - stm32f777
          - stm32f778
          - stm32f779
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
        run: |
          rustup set profile minimal
          rustup override set ${{ matrix.toolchain }}
          rustup target add ${{ matrix.target }}

      - name: cargo build
        run: |
          cargo build --release --target=${{ matrix.target }} --features ${{ matrix.features }}

  build-feature-mixer:
    name: build-feature-mixer
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          - x86_64-unknown-linux-gnu
        features:
          - "ptp,async-await"
          - "ptp"
          - "async-await"
          - "smoltcp-phy"
          - ""
        toolchain:
          - stable
        mcu:
          - stm32f107
          - stm32f407
          - stm32f745
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
        run: |
          rustup set profile minimal
          rustup override set ${{ matrix.toolchain }}
          rustup target add ${{ matrix.target }}

      - name: cargo build
        run: |
          cargo build --release --target=${{ matrix.target }} --features "${{ matrix.mcu }}" --features "${{ matrix.features }}" --no-default-features

  # Test that all of the examples compile
  # for stm32f429
  examples:
    name: examples
    runs-on: ubuntu-latest
    strategy:
      matrix:
        example:
          - example: arp
            features: ""
          - example: ip
            features: smoltcp-phy
          - example: pktgen
            features: ""
          - example: rtic-echo
            features: smoltcp-phy
          - example: rtic-timestamp
            features: ""
          - example: timesync-server
            features: ptp
          - example: timesync-client
            features: ptp
          - example: smoltcp-client
            features: ptp,smoltcp-phy
          - example: smoltcp-server
            features: ptp,smoltcp-phy
        toolchain:
          - stable
        target:
          - thumbv7em-none-eabi
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
        run: |
          rustup set profile minimal
          rustup override set ${{ matrix.toolchain }}
          rustup target add ${{ matrix.target }}

      - name: Build example ${{ matrix.example.example }} for stm32f429
        run: |
          cargo build --release --target=${{ matrix.target }} --example ${{ matrix.example.example }} --features stm32f429,${{ matrix.example.features }}
  
  # Test that all the code shared with other MCU families also compiles
  examples-common:
    name: examples-common
    runs-on: ubuntu-latest
    strategy:
      matrix:
        toolchain:
          - stable
        target:
          - thumbv7em-none-eabi
        mcu:
          - stm32f107
          - stm32f429
          - stm32f745
        pins:
          - nucleo
          - default
        pps:
          - default
          - alternate
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
        run: |
          rustup set profile minimal
          rustup override set ${{ matrix.toolchain }}
          rustup target add ${{ matrix.target }}

      - name: Build examples common file for ${{ matrix.mcu }}, eth pins ${{ matrix.pins }}, pps pin ${{ matrix.pps }}
        run: |
          STM32_ETH_EXAMPLE_PPS_PIN=${{ matrix.pps}} STM32_ETH_EXAMPLE_PINS=${{ matrix.pins }} cargo check --release --target=${{ matrix.target }} --example common --features ${{ matrix.mcu }},defmt,smoltcp-phy,ptp

  # Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149
  #
  # ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB!

  ci-success:
    name: ci
    if: github.event_name == 'push' && success()
    needs:
      - style
      - build
      - test
      - examples
      - examples-common
      - build-feature-mixer
    runs-on: ubuntu-latest
    steps:
      - name: Mark the job as a success
        run: exit 0