name: ci
on: [push, pull_request]

jobs:
  check:
    name: Check build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: "thumbv7em-none-eabihf"
      - run: cargo check --target thumbv7em-none-eabihf
      - run: cargo check --target thumbv7em-none-eabihf --examples
      - run: cargo check -p va416xx --target thumbv7em-none-eabihf --all-features
      - run: cargo check -p va416xx-hal --target thumbv7em-none-eabihf --features "defmt"

  fmt:
    name: Check formatting
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo fmt --all -- --check

  docs:
    name: Check Documentation Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@nightly
      - run: RUSTDOCFLAGS="--cfg docsrs --generate-link-to-definition -Z unstable-options" cargo +nightly doc -p va416xx --all-features
      - run: RUSTDOCFLAGS="--cfg docsrs --generate-link-to-definition -Z unstable-options" cargo +nightly doc -p va416xx-hal --features "defmt va41630"
      - run: RUSTDOCFLAGS="--cfg docsrs --generate-link-to-definition -Z unstable-options" cargo +nightly doc -p vorago-peb1

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: "thumbv7em-none-eabihf"
      - run: cargo clippy --target thumbv7em-none-eabihf -- -D warnings
