Skip to content

Commit 1bc0cc9

Browse files
committed
fix(caching): /target directory cleanup on Cargo.lock changes
1 parent 350d06d commit 1bc0cc9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

.github/workflows/ci-check-app.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
components: clippy
8585

8686
- name: Restore Cargo cache
87+
id: cache-restore
8788
uses: actions/cache/restore@v4
8889
with:
8990
path: |
@@ -95,6 +96,10 @@ jobs:
9596
restore-keys: |
9697
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-clippy-
9798
99+
- name: Clean target if Cargo.lock changed
100+
if: steps.cache-restore.outputs.cache-hit != 'true'
101+
run: rm -rf target/
102+
98103
- name: Install Protoc
99104
if: ${{ inputs.install-protoc == true }}
100105
uses: arduino/setup-protoc@v3
@@ -135,6 +140,7 @@ jobs:
135140
components: rustfmt
136141

137142
- name: Restore Cargo cache
143+
id: cache-restore
138144
uses: actions/cache/restore@v4
139145
with:
140146
path: |
@@ -146,6 +152,10 @@ jobs:
146152
restore-keys: |
147153
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-formatting-
148154
155+
- name: Clean target if Cargo.lock changed
156+
if: steps.cache-restore.outputs.cache-hit != 'true'
157+
run: rm -rf target/
158+
149159
- name: Run sccache-cache
150160
if: ${{ inputs.use-sccache == true }}
151161
uses: mozilla-actions/sccache-action@v0.0.4
@@ -180,6 +190,7 @@ jobs:
180190
toolchain: ${{ inputs.rust-toolchain }}
181191

182192
- name: Restore Cargo cache
193+
id: cache-restore
183194
uses: actions/cache/restore@v4
184195
with:
185196
path: |
@@ -191,6 +202,10 @@ jobs:
191202
restore-keys: |
192203
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-
193204
205+
- name: Clean target if Cargo.lock changed
206+
if: steps.cache-restore.outputs.cache-hit != 'true'
207+
run: rm -rf target/
208+
194209
- name: Install Protoc
195210
if: ${{ inputs.install-protoc == true }}
196211
uses: arduino/setup-protoc@v3
@@ -244,6 +259,7 @@ jobs:
244259
toolchain: ${{ inputs.rust-toolchain }}
245260

246261
- name: Restore Cargo cache
262+
id: cache-restore
247263
uses: actions/cache/restore@v4
248264
with:
249265
path: |
@@ -255,6 +271,10 @@ jobs:
255271
restore-keys: |
256272
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-suites-
257273
274+
- name: Clean target if Cargo.lock changed
275+
if: steps.cache-restore.outputs.cache-hit != 'true'
276+
run: rm -rf target/
277+
258278
- name: Install Protoc
259279
if: ${{ inputs.install-protoc == true }}
260280
uses: arduino/setup-protoc@v3
@@ -296,6 +316,7 @@ jobs:
296316
toolchain: ${{ inputs.rust-toolchain-udeps }}
297317

298318
- name: Restore Cargo cache
319+
id: cache-restore
299320
uses: actions/cache/restore@v4
300321
with:
301322
path: |
@@ -307,6 +328,10 @@ jobs:
307328
restore-keys: |
308329
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-unused-deps-
309330
331+
- name: Clean target if Cargo.lock changed
332+
if: steps.cache-restore.outputs.cache-hit != 'true'
333+
run: rm -rf target/
334+
310335
- name: Run sccache-cache
311336
if: ${{ inputs.use-sccache == true }}
312337
uses: mozilla-actions/sccache-action@v0.0.4

examples/sub-validate.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
toolchain: ${{ vars.RUST_VERSION }}
4747

4848
- name: Restore Cargo cache
49+
id: cache-restore
4950
uses: actions/cache/restore@v4
5051
with:
5152
path: |
@@ -57,6 +58,10 @@ jobs:
5758
restore-keys: |
5859
v0-rust-${{ runner.os }}-cargo-integration-
5960
61+
- name: Clean target if Cargo.lock changed
62+
if: steps.cache-restore.outputs.cache-hit != 'true'
63+
run: rm -rf target/
64+
6065
- name: "Run Integration Tests"
6166
env:
6267
PROJECT_ID: ${{ secrets.PROJECT_ID }}

0 commit comments

Comments
 (0)