name: CI
on:
push:
branches:
- main
pull_request:
env:
RUST_TOOLCHAIN: "1.94"
RUST_TOOLCHAIN_COMPONENTS: rustfmt, clippy
RUST_BACKTRACE: short
RUSTFLAGS: "-D warnings"
jobs:
test-and-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Rust cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: ${{ env.RUST_TOOLCHAIN_COMPONENTS }}
- name: Check source code format
run: cargo fmt -- --check
- name: Run tests
run: cargo test
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings