name: Rust
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy, llvm-tools-preview
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --check
- name: Install cargo-readme
uses: taiki-e/install-action@v2
with:
tool: cargo-readme
- name: Check README.md is up to date
run: |
cargo readme -o README.md
git diff --exit-code -- README.md \
|| (echo "README.md is stale, run 'cargo readme -o README.md'" >&2; exit 1)
- name: Run clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: Build documentation
env:
RUSTDOCFLAGS: "-D warnings"
run: cargo doc --workspace --all-features --no-deps
- name: Security Audit
uses: rustsec/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests (default features)
run: cargo test --workspace --verbose
- name: Run tests (no default features)
run: cargo test --workspace --no-default-features --verbose
- name: Run tests (all features)
run: cargo test --workspace --all-features --verbose
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Code Coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: lcov.info