name: CI
on:
push:
branches: [main, master]
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
TARGET: riscv32imfc-unknown-none-elf
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup show active-toolchain
- run: cargo fmt --all --check
register-access:
name: Register access policy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: python3 scripts/check-register-access.py
stable-api:
name: Stable API snapshot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup show active-toolchain
- run: cargo install cargo-public-api --version 0.52.0 --locked
- run: scripts/check-stable-api.sh --check
- run: scripts/check-rename-api.sh
- name: Stable-only rustdoc has no private links
run: cargo doc --locked --no-deps --no-default-features --features chip-ws63
env:
RUSTFLAGS: --cfg instability_disable_unstable_docs
RUSTDOCFLAGS: -D warnings
clippy:
name: Clippy
runs-on: ubuntu-latest
strategy:
matrix:
features: ["chip-ws63,rt,async,embassy", "chip-ws63,rt,async,embassy,defmt", "chip-bs21,rt,unstable"]
steps:
- uses: actions/checkout@v4
- run: rustup show active-toolchain
- run: cargo clippy -Zbuild-std=core,alloc --target "$TARGET" --locked --no-default-features --features "${{ matrix.features }}" -- -D warnings
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
features: ["chip-ws63,rt,async,embassy", "chip-ws63,rt,async,embassy,defmt", "chip-bs21,rt,unstable"]
steps:
- uses: actions/checkout@v4
- run: rustup show active-toolchain
- run: cargo check -Zbuild-std=core,alloc --target "$TARGET" --locked --no-default-features --features "${{ matrix.features }}"
- run: cargo check -Zbuild-std=core,alloc --target "$TARGET" --locked --no-default-features --features "${{ matrix.features }}" --release
bs2x-gate:
name: BS2X requires unstable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup show active-toolchain
- run: |
if cargo check -Zbuild-std=core,alloc --target "$TARGET" --locked --no-default-features --features chip-bs21,rt 2>bs2x-stable.log; then
printf 'chip-bs21 built without unstable\n'
exit 1
fi
grep -q 'BS2X support is experimental' bs2x-stable.log
doc:
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup show active-toolchain
- run: cargo doc -Zbuild-std=core,alloc --target "$TARGET" --locked --no-deps --document-private-items --no-default-features --features "chip-ws63,rt,async,embassy"
env:
RUSTDOCFLAGS: -D warnings
semver:
name: SemVer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Detect published package baseline
id: baseline
run: |
if cargo search '^hisi-hal$' --limit 1 | grep -q '^hisi-hal = '; then
echo 'available=true' >> "$GITHUB_OUTPUT"
else
echo 'available=false' >> "$GITHUB_OUTPUT"
fi
- name: cargo-semver-checks (vs last crates.io release)
if: steps.baseline.outputs.available == 'true'
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
feature-group: only-explicit-features
features: chip-ws63