Add cargo data caching to CI workflow #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
paths: | |
- .github/workflows/ci.yaml | |
- 'firmware/**' | |
pull_request: | |
paths: | |
- .github/workflows/ci.yaml | |
- 'firmware/**' | |
env: | |
CARGO_TERM_COLOR: always | |
defaults: | |
run: | |
working-directory: firmware | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: riscv32imc-unknown-none-elf | |
components: clippy, rust-src, rustfmt | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Cache cargo data | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/git | |
~/.cargo/registry | |
# intentionally not caching `target/` here yet | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check formatting | |
run: cargo fmt --all --check | |
- name: Clippy | |
run: cargo clippy --workspace --all-targets --all-features -- --deny warnings --allow deprecated | |
build: | |
name: Build | |
needs: [check] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: riscv32imc-unknown-none-elf | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Cache cargo data | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/git | |
~/.cargo/registry | |
# intentionally not caching `target/` here yet | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build everything | |
run: cargo build --workspace --all-targets --release |