Skip to content

Commit 79b5770

Browse files
committed
ci: Use Swatinem/rust-cache action
This is simpler and more effective than our manual implementation. Unfortunately, this is completely ineffective on nightly, since it always keyed by the rust version and will not restore from other versions. While this is sensible behavior for the target directory, it means we cannot cache the registry index on nightly. Luckily, nightly rust uses the sparse index by default, meaning downloading it is fast anyways.
1 parent 73bf185 commit 79b5770

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

.github/workflows/clippy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
with:
3333
toolchain: ${{ matrix.rust }}
3434
components: clippy
35+
- uses: Swatinem/rust-cache@v2
36+
if: ${{ matrix.rust != 'nightly' }}
3537
- name: Clippy
3638
run: |
3739
cargo clippy --all --all-targets --verbose --all-features -- -D warnings

.github/workflows/test.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,8 @@ jobs:
7575
- uses: dtolnay/rust-toolchain@master
7676
with:
7777
toolchain: ${{ matrix.rust }}
78-
- name: Cache Cargo Registry
79-
id: cache-index
80-
uses: actions/cache@v4
81-
with:
82-
path:
83-
# Before the sparse index, updating the registry took forever
84-
~/.cargo/registry/index/
85-
key: ${{ runner.os }}-cargo-${{ matrix.rust }}
86-
restore-keys: |
87-
${{ runner.os }}-cargo-
78+
- uses: Swatinem/rust-cache@v2
79+
if: ${{ matrix.rust != 'nightly' }} # ineffective due to version key
8880
- name: Check
8981
run: |
9082
cargo check --all-targets --verbose --no-default-features --features "${{ matrix.features }}"

0 commit comments

Comments
 (0)