name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo registry and git checkouts
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache build artifacts
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Check code formatting with rustfmt
run: cargo fmt -- --check
- name: Run clippy linter (deny warnings)
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run cargo check (fast compile check)
run: cargo check --all-targets --all-features
- name: Build release
run: cargo build --release
- name: Run tests
run: cargo test --all -- --nocapture