name: Rust
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Run fmt
run: |
rustup component add rustfmt --toolchain stable || true
cargo fmt -- --check
- name: Run clippy
run: |
rustup component add clippy --toolchain stable || true
cargo clippy --all-targets -- -D warnings
- name: Run tests
run: cargo test --all