Skip to content

Commit

Permalink
Overhaul build cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Dec 5, 2024
1 parent 815123e commit b9bce71
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
env:
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0 # makes cache smaller
CARGO_PROFILE_DEV_DEBUG: 0

jobs:
clippy:
Expand All @@ -18,39 +20,49 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Install rustfmt
run: rustup component add rustfmt
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Check format
run: cargo fmt -- --check
- name: Cache cargo index and registry
- name: Cache cargo index
uses: actions/cache@v4
with:
key: immutable # this will always be hit because it's a constant
path: |
~/.cargo/registry/cache
~/.cargo/registry/index
- name: Create lockfile
run: cargo generate-lockfile
- name: Fetch dependencies
run: cargo fetch
- name: Cache target directory
path: ~/.cargo/registry/index
- name: Cache cargo crates
uses: actions/cache@v4
with:
path: target
key: clippy-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
key: crates-${{ hashFiles('Cargo.toml') }} # don't accumulate .crate files of old versions
path: ~/.cargo/registry/cache # target/ dir of clippy is not worth caching
- name: Fetch dependencies
run: cargo fetch
- name: Run clippy
run: cargo clippy --all --all-targets
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (rustup)
run: rustup update stable --no-self-update && rustup default stable
- name: Get rust version
id: rust-version
run: echo "::set-output name=version::$(rustc --version)"
- name: Run Rust tests
run: scripts/test.sh
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo index and registry
uses: actions/cache@v4
with:
key: immutable
path: ~/.cargo/registry/index
- name: Cache cargo crates
uses: actions/cache@v4
with:
key: crates-${{ hashFiles('Cargo.toml') }} # don't accumulate .crate files of old versions
path: ~/.cargo/registry/cache
- name: Fetch dependencies
run: cargo fetch
- name: Cache target directory
uses: actions/cache@v4
with:
path: target
key: target-${{ hashFiles('Cargo.toml') }}
- name: Run Rust tests
run: scripts/test.sh

0 comments on commit b9bce71

Please sign in to comment.