embedded-test 0.7.1

A test harness and runner for embedded devices
Documentation
# This action builds* all the pushes to master, staging and trying which are required for bors.
# Additionally it builds* for each PR.
#
# * builds includes building, checking, testing, checking format and clippy, as well as the changelog.

on:
  push:
    branches: [ master, staging, trying, next ]
  pull_request:
  merge_group:

# Cancel any currently running workflows from the same PR, branch, or
# tag when a new workflow is triggered.
#
# https://stackoverflow.com/a/66336834
concurrency:
  cancel-in-progress: true
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

name: Run CI

jobs:
  check:
    name: Check
    strategy:
      matrix:
        toolchain:
          - stable
          - nightly
          #os:
          #- ubuntu-latest
          #- windows-latest
          #- macos-14
        log_kind:
          - log
          - defmt

        target_and_example: [
          # RISC-V devices:
          { target: "riscv32imac-unknown-none-elf", example: "examples/esp32c6/Cargo.toml", features: "default" },
          # arm7 devices:
          { target: "thumbv7em-none-eabihf", example: "examples/stm32f767/Cargo.toml", features: "default" },
          # std:
          { target: "x86_64-unknown-linux-gnu", example: "examples/std/Cargo.toml", features: "std" },
        ]

        exclude:
          - log_kind: defmt
            target_and_example: { target: "x86_64-unknown-linux-gnu", example: "examples/std/Cargo.toml", features: "std" }

    runs-on: ubuntu-latest #${{ matrix.os }}

    env:
      VCPKGRS_DYNAMIC: 1 # Use dynamic linking on Windows build (vcpkg)

    steps:
      - name: Checkout sources
        uses: actions/checkout@v4

      - name: Install target
        uses: dtolnay/rust-toolchain@v1
        with:
          target: ${{ matrix.target_and_example.target}}
          toolchain: ${{ matrix.toolchain }}
          components: rust-src

      - name: Cache Dependencies
        uses: Swatinem/rust-cache@v2.7.5

      - name: Run cargo check for embedded-test
        run: cargo check --target ${{ matrix.target_and_example.target}} --no-default-features --features ${{matrix.log_kind}},${{matrix.target_and_example.features}} --locked

      - name: Run cargo check for example
        run: cargo check --target ${{ matrix.target_and_example.target}} --no-default-features --features ${{matrix.log_kind}} --manifest-path ${{matrix.target_and_example.example}} --locked --all-targets

  ui_tests:
    name: Compile Tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4

      - name: Install target
        uses: dtolnay/rust-toolchain@v1
        with:
          target: riscv32imac-unknown-none-elf
          toolchain: stable
          components: rust-src

      - name: Cache Dependencies
        uses: Swatinem/rust-cache@v2.7.5

      - name: Run Compile tests
        run: cd tests-build && cargo test -- --test-threads 1

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4

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

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4

      - name: Install riscv32imac-unknown-none-elf target
        run: rustup target add riscv32imac-unknown-none-elf

      - name: Cache Dependencies
        uses: Swatinem/rust-cache@v2.7.5

      - name: Run cargo clippy
        run: cargo clippy --locked -- -D warnings

      - name: Run cargo clippy on macros crate
        run: cd macros && cargo clippy --locked -- -D warnings