name: CI
on:
push:
branches: [main]
pull_request:
branches: ["*"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
rust:
name: Rust build, fmt, clippy, tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [stable, "1.72.0"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust (${{ matrix.toolchain }})
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy
- name: Cache cargo build artefacts
uses: Swatinem/rust-cache@v2
with:
workspaces: |
. -> target
- name: Show toolchain versions
run: |
rustc --version
cargo --version
- name: Cargo fmt (check)
run: cargo fmt --all -- --check
- name: Cargo clippy (warnings as errors)
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Cargo tests
run: cargo test --all --locked --no-fail-fast