Skip to content

Commit a762609

Browse files
committed
Upgrade project cache to a rust specific action
`Swatinem/rust-cache` is built on top of the upstream cache action maintained by GitHub but add rust specific tweaks to avoid cache rot + some works arround for common rust cache issues.
1 parent dc284e6 commit a762609

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,10 @@ jobs:
7474
toolchain: stable
7575
override: true
7676

77-
- uses: actions/cache@v3
78-
name: Cache Cargo.lock
77+
- name: Rust Cache
78+
uses: Swatinem/rust-cache@v2
7979
with:
80-
path: |
81-
~/.cargo/bin/
82-
~/.cargo/registry/
83-
~/.cargo/git/
84-
target/
85-
key: cargo-${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}-${{ matrix.project }}-${{ hashFiles('Cargo.lock') }}
86-
restore-keys: |
87-
cargo-${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}-${{ matrix.project }}-
88-
cargo-${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}-
80+
key: ${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}
8981

9082
- name: Install cargo tools
9183
if: ${{ steps.cargo-cache.outputs.cache-hit == false }}
@@ -139,7 +131,7 @@ jobs:
139131
override: true
140132

141133
- name: Rust Cache
142-
uses: Swatinem/rust-cache@v2.0.1
134+
uses: Swatinem/rust-cache@v2
143135
with:
144136
key: ${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}
145137

@@ -187,26 +179,15 @@ jobs:
187179
toolchain: stable
188180
override: true
189181

190-
# Get the matrix build cache for mithril-core
191-
# Note: cargo tools will be included so there's no need to install them
192-
- uses: actions/cache@v3
193-
name: Cache Cargo.lock
182+
- name: Rust Cache
183+
uses: Swatinem/rust-cache@v2
194184
with:
195-
path: |
196-
~/.cargo/bin/
197-
~/.cargo/registry/
198-
~/.cargo/git/
199-
target/
200-
key: cargo-${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}-mithril-core-${{ hashFiles('Cargo.lock') }}
201-
restore-keys: |
202-
cargo-${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}-mithril-core
203-
cargo-${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}-
185+
key: ${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}
204186

205187
- name: Install cargo tools
206188
if: ${{ steps.cargo-cache.outputs.cache-hit == false }}
207189
run: |
208190
cargo install cargo2junit 2>/dev/null || true # Suppress the "binary `xyz` already exists in destination" error
209-
cargo install cargo-sort 2>/dev/null || true
210191
211192
- name: Cargo build
212193
uses: actions-rs/cargo@v1

0 commit comments

Comments
 (0)