Skip to content

Commit a8cdc08

Browse files
standardize cache keys for rustup and cargo deps across workflows
1 parent 35f233a commit a8cdc08

File tree

2 files changed

+72
-12
lines changed

2 files changed

+72
-12
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ jobs:
8181
with:
8282
path: |
8383
~/.rustup
84-
key: ${{ runner.os }}-${{ matrix.platform.target }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
84+
key: ${{ runner.os }}-${{ runner.arch }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
8585
restore-keys: |
86-
${{ runner.os }}-${{ matrix.platform.target }}-rustup-
86+
${{ runner.os }}-${{ runner.arch }}-rustup-
8787
8888
- name: Cache Homebrew packages (macOS)
8989
if: ${{ runner.os == 'macOS' }}
@@ -283,20 +283,20 @@ jobs:
283283
with:
284284
path: |
285285
~/.rustup
286-
key: ${{ runner.os }}-${{ matrix.platform.target }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
286+
key: ${{ runner.os }}-${{ runner.arch }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
287287
restore-keys: |
288-
${{ runner.os }}-${{ matrix.platform.target }}-rustup-
288+
${{ runner.os }}-${{ runner.arch }}-rustup-
289289
290290
- name: Cache Cargo registry
291291
uses: actions/cache@v4
292292
with:
293293
path: |
294294
~/.cargo/git
295295
~/.cargo/registry
296-
key: ${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo.lock') }}
296+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
297297
restore-keys: |
298-
${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-
299-
${{ runner.os }}-cargo-wheels-
298+
${{ runner.os }}-${{ runner.arch }}-cargo-registry-
299+
${{ runner.os }}-cargo-registry-
300300
301301
- name: Build wheels
302302
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380
@@ -334,20 +334,20 @@ jobs:
334334
with:
335335
path: |
336336
~/.rustup
337-
key: ${{ runner.os }}-${{ matrix.platform.target }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
337+
key: ${{ runner.os }}-${{ runner.arch }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
338338
restore-keys: |
339-
${{ runner.os }}-${{ matrix.platform.target }}-rustup-
339+
${{ runner.os }}-${{ runner.arch }}-rustup-
340340
341341
- name: Cache Cargo registry
342342
uses: actions/cache@v4
343343
with:
344344
path: |
345345
~/.cargo/git
346346
~/.cargo/registry
347-
key: ${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo.lock') }}
347+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
348348
restore-keys: |
349-
${{ runner.os }}-cargo-wheels-${{ matrix.platform.target }}-
350-
${{ runner.os }}-cargo-wheels-
349+
${{ runner.os }}-${{ runner.arch }}-cargo-registry-
350+
${{ runner.os }}-cargo-registry-
351351
352352
- name: Build wheels
353353
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380

.github/workflows/lint.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,26 @@ jobs:
7777
with:
7878
persist-credentials: false
7979

80+
- name: Cache rustup toolchain
81+
uses: actions/cache@v4
82+
with:
83+
path: |
84+
~/.rustup
85+
key: ${{ runner.os }}-${{ runner.arch }}-rustup-nightly-${{ hashFiles('.github/workflows/lint.yml') }}
86+
restore-keys: |
87+
${{ runner.os }}-${{ runner.arch }}-rustup-nightly-
88+
89+
- name: Cache Cargo dependencies
90+
uses: actions/cache@v4
91+
with:
92+
path: |
93+
~/.cargo/git
94+
~/.cargo/registry
95+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
96+
restore-keys: |
97+
${{ runner.os }}-${{ runner.arch }}-cargo-registry-
98+
${{ runner.os }}-cargo-registry-
99+
80100
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
81101
with:
82102
toolchain: nightly
@@ -94,6 +114,26 @@ jobs:
94114
with:
95115
persist-credentials: false
96116

117+
- name: Cache rustup toolchain
118+
uses: actions/cache@v4
119+
with:
120+
path: |
121+
~/.rustup
122+
key: ${{ runner.os }}-${{ runner.arch }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
123+
restore-keys: |
124+
${{ runner.os }}-${{ runner.arch }}-rustup-
125+
126+
- name: Cache Cargo dependencies
127+
uses: actions/cache@v4
128+
with:
129+
path: |
130+
~/.cargo/git
131+
~/.cargo/registry
132+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
133+
restore-keys: |
134+
${{ runner.os }}-${{ runner.arch }}-cargo-registry-
135+
${{ runner.os }}-cargo-registry-
136+
97137
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
98138
with:
99139
components: clippy
@@ -110,6 +150,26 @@ jobs:
110150
with:
111151
persist-credentials: false
112152

153+
- name: Cache rustup toolchain
154+
uses: actions/cache@v4
155+
with:
156+
path: |
157+
~/.rustup
158+
key: ${{ runner.os }}-${{ runner.arch }}-rustup-${{ hashFiles('rust-toolchain.toml') }}
159+
restore-keys: |
160+
${{ runner.os }}-${{ runner.arch }}-rustup-
161+
162+
- name: Cache Cargo registry
163+
uses: actions/cache@v4
164+
with:
165+
path: |
166+
~/.cargo/git
167+
~/.cargo/registry
168+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
169+
restore-keys: |
170+
${{ runner.os }}-${{ runner.arch }}-cargo-registry-
171+
${{ runner.os }}-cargo-registry-
172+
113173
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
114174

115175
- name: Run cargo check

0 commit comments

Comments
 (0)