name: Rust CI
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@v2
with:
tool: cargo-all-features
- name: Check all feature combinations
run: cargo check-all-features
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: cargo clippy -- -D warnings
run: cargo clippy --all-features -- -D warnings
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Format
run: cargo fmt --check
test:
strategy:
matrix:
toolchain: [stable, beta]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: cargo-all-features
- name: Test all feature combinations
run: cargo test-all-features
no_std:
runs-on: ubuntu-latest
strategy:
matrix:
target: [ thumbv7m-none-eabi, aarch64-unknown-none ]
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Check
run: cargo check --target ${{ matrix.target }}
- name: Build
run: cargo build --target ${{ matrix.target }}
doc:
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: --cfg docsrs
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- name: Generate documentation
run: cargo +nightly doc --all-features
verify_msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: cargo-msrv
- name: Verify MSRV
run: cargo msrv verify
semver_checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@v2
with:
tool: cargo-semver-checks
- name: Check for semver violations
run: cargo semver-checks
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: Generate coverage reports
run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true