name: rust
on:
push:
branches:
- main
pull_request:
schedule:
- cron: '37 6 * * *'
env:
CARGO_TERM_COLOR: always
jobs:
build_test:
strategy:
fail-fast: false
matrix:
is_pr_or_push:
- ${{github.event_name == 'pull_request' || github.event_name == 'push'}}
target:
- triple: x86_64-unknown-linux-gnu
runner: linux-x86_64-16cpu
- triple: aarch64-unknown-linux-gnu
runner: linux-arm64-16cpu
- triple: aarch64-apple-darwin
runner: macos-26
toolchain:
- version: 1.93.1
label: prev
- version: 1.94.0
label: latest
exclude:
- is_pr_or_push: true
target:
triple: aarch64-apple-darwin
name: test (rust ${{ matrix.toolchain.label }}, ${{ matrix.target.triple }})
runs-on: ${{ matrix.target.runner }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up cache
id: cache-cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.rustup/toolchains
target/
key: ${{ matrix.target.runner }}-cargo+machete-${{ matrix.toolchain.version }}-${{ matrix.target.triple }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
id: install-toolchain
if: steps.cache-cargo.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain.version }}
components: clippy
- name: Install nightly Rust toolchain
id: install-nightly-toolchain
if: steps.cache-cargo.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt
- name: binstall
uses: cargo-bins/cargo-binstall@main
- name: Install cargo-deny
if: steps.cache-cargo.outputs.cache-hit != 'true'
run: cargo binstall --no-confirm cargo-deny
- name: Check for unused dependencies (cargo machete)
uses: bnjbvr/cargo-machete@main
with:
args: "--with-metadata"
- name: Dependency audit (cargo deny)
run: cargo deny --workspace --all-features check all
- name: Check formatting (cargo fmt)
run: cargo +nightly fmt --check
- name: Custom workspace checks
run: cargo +${{ matrix.toolchain.version }} run -p checks
- name: Lint lib targets (cargo clippy)
run: |-
cargo +${{ matrix.toolchain.version }} clippy \
--all-features --workspace --no-deps \
--lib \
--target ${{ matrix.target.triple }} \
-- -D warnings
- name: Lint other targets (cargo clippy)
run: |-
cargo +${{ matrix.toolchain.version }} clippy \
--all-features --workspace --no-deps \
--bins --tests --benches --examples \
--target ${{ matrix.target.triple }} \
-- -D warnings -A missing_docs
- name: Build (cargo build)
run: cargo +${{ matrix.toolchain.version }} build --all-features --workspace --verbose --all-targets --target ${{ matrix.target.triple }}
- name: Test (cargo test)
run: cargo +${{ matrix.toolchain.version }} test --all-features --workspace --verbose --target ${{ matrix.target.triple }}
- name: Release build (cargo build --release)
run: cargo +${{ matrix.toolchain.version }} build --all-features --workspace --release --verbose --all-targets --target ${{ matrix.target.triple }}
- name: Docs (cargo doc)
run: cargo +${{ matrix.toolchain.version }} doc --workspace --no-deps --all-features --target ${{ matrix.target.triple }}