name: CI
on:
workflow_dispatch:
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check (${{ matrix.toolchain }})
runs-on: ubuntu-latest
strategy:
matrix:
toolchain: [stable, nightly]
steps:
- uses: actions/checkout@v6
- name: Install Rust ${{ matrix.toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- name: Cache cargo registry and build
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml') }}
- name: Check formatting
run: cargo fmt --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Build
run: cargo build
- name: Run tests
run: cargo test