Skip to content

Commit 62c8922

Browse files
committed
Add cache cleaning if cache wasn't hit
1 parent de0f66d commit 62c8922

File tree

1 file changed

+49
-13
lines changed

1 file changed

+49
-13
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v3
1515
- uses: actions/cache@v3
16+
id: cargo-cache
1617
with:
1718
path: |
1819
~/.cargo/bin/
1920
~/.cargo/registry/index/
2021
~/.cargo/registry/cache/
2122
~/.cargo/git/db/
22-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
23+
key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }}
2324
restore-keys: |
24-
${{ runner.os }}-cargo
25+
${{ runner.os }}-cargo-dependencies
2526
- uses: actions-rs/toolchain@v1
2627
with:
2728
toolchain: 1.59.0
@@ -40,6 +41,11 @@ jobs:
4041
with:
4142
command: test
4243
args: --all --verbose --exclude rage --all-features
44+
- name: Autoclean the cache
45+
if: steps.cargo-cache.outputs.cache-hit != 'true'
46+
run:
47+
cargo install --no-default-features --features ci-autoclean cargo-cache
48+
cargo-cache
4349

4450
build:
4551
name: Build target ${{ matrix.target }}
@@ -52,15 +58,16 @@ jobs:
5258
steps:
5359
- uses: actions/checkout@v3
5460
- uses: actions/cache@v3
61+
id: cargo-cache
5562
with:
5663
path: |
5764
~/.cargo/bin/
5865
~/.cargo/registry/index/
5966
~/.cargo/registry/cache/
6067
~/.cargo/git/db/
61-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
68+
key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }}
6269
restore-keys: |
63-
${{ runner.os }}-cargo
70+
${{ runner.os }}-cargo-dependencies
6471
- uses: actions-rs/toolchain@v1
6572
with:
6673
toolchain: 1.59.0
@@ -74,6 +81,11 @@ jobs:
7481
- name: Build for target
7582
working-directory: ./age
7683
run: cargo build --verbose --no-default-features --target ${{ matrix.target }}
84+
- name: Autoclean the cache
85+
if: steps.cargo-cache.outputs.cache-hit != 'true'
86+
run:
87+
cargo install --no-default-features --features ci-autoclean cargo-cache
88+
cargo-cache
7789

7890
bitrot:
7991
name: Bitrot
@@ -82,15 +94,16 @@ jobs:
8294
steps:
8395
- uses: actions/checkout@v3
8496
- uses: actions/cache@v3
97+
id: cargo-cache
8598
with:
8699
path: |
87100
~/.cargo/bin/
88101
~/.cargo/registry/index/
89102
~/.cargo/registry/cache/
90103
~/.cargo/git/db/
91-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
104+
key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }}
92105
restore-keys: |
93-
${{ runner.os }}-cargo
106+
${{ runner.os }}-cargo-dependencies
94107
- uses: actions-rs/toolchain@v1
95108
with:
96109
toolchain: 1.59.0
@@ -102,6 +115,11 @@ jobs:
102115
with:
103116
command: check
104117
args: --tests --examples --benches --all-features
118+
- name: Autoclean the cache
119+
if: steps.cargo-cache.outputs.cache-hit != 'true'
120+
run:
121+
cargo install --no-default-features --features ci-autoclean cargo-cache
122+
cargo-cache
105123

106124
clippy:
107125
name: Clippy (1.59.0)
@@ -110,15 +128,16 @@ jobs:
110128
steps:
111129
- uses: actions/checkout@v3
112130
- uses: actions/cache@v3
131+
id: cargo-cache
113132
with:
114133
path: |
115134
~/.cargo/bin/
116135
~/.cargo/registry/index/
117136
~/.cargo/registry/cache/
118137
~/.cargo/git/db/
119-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
138+
key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }}
120139
restore-keys: |
121-
${{ runner.os }}-cargo
140+
${{ runner.os }}-cargo-dependencies
122141
- uses: actions-rs/toolchain@v1
123142
with:
124143
toolchain: 1.59.0
@@ -132,6 +151,11 @@ jobs:
132151
name: Clippy (1.59.0)
133152
token: ${{ secrets.GITHUB_TOKEN }}
134153
args: --all-features --all-targets -- -D warnings
154+
- name: Autoclean the cache
155+
if: steps.cargo-cache.outputs.cache-hit != 'true'
156+
run:
157+
cargo install --no-default-features --features ci-autoclean cargo-cache
158+
cargo-cache
135159

136160
codecov:
137161
name: Code coverage
@@ -140,15 +164,16 @@ jobs:
140164
steps:
141165
- uses: actions/checkout@v3
142166
- uses: actions/cache@v3
167+
id: cargo-cache
143168
with:
144169
path: |
145170
~/.cargo/bin/
146171
~/.cargo/registry/index/
147172
~/.cargo/registry/cache/
148173
~/.cargo/git/db/
149-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
174+
key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }}
150175
restore-keys: |
151-
${{ runner.os }}-cargo
176+
${{ runner.os }}-cargo-dependencies
152177
- uses: actions-rs/toolchain@v1
153178
with:
154179
toolchain: stable
@@ -164,6 +189,11 @@ jobs:
164189
uses: codecov/[email protected]
165190
with:
166191
fail_ci_if_error: true
192+
- name: Autoclean the cache
193+
if: steps.cargo-cache.outputs.cache-hit != 'true'
194+
run:
195+
cargo install --no-default-features --features ci-autoclean cargo-cache
196+
cargo-cache
167197

168198
doc-links:
169199
name: Intra-doc links
@@ -172,15 +202,15 @@ jobs:
172202
steps:
173203
- uses: actions/checkout@v3
174204
- uses: actions/cache@v3
205+
id: cargo-cache
175206
with:
176207
path: |
177208
~/.cargo/bin/
178209
~/.cargo/registry/index/
179210
~/.cargo/registry/cache/
180211
~/.cargo/git/db/
181-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
182-
restore-keys: |
183-
${{ runner.os }}-cargo
212+
key: ${{ runner.os }}-cargo-dependencies-${{ hashFiles('**/Cargo.lock') }}
213+
${{ runner.os }}-cargo-dependencies
184214
- uses: actions-rs/toolchain@v1
185215
with:
186216
toolchain: 1.59.0
@@ -197,6 +227,12 @@ jobs:
197227
with:
198228
command: doc
199229
args: --all --exclude rage --all-features --document-private-items
230+
- name: Autoclean the cache
231+
if: steps.cargo-cache.outputs.cache-hit != 'true'
232+
run:
233+
cargo install --no-default-features --features ci-autoclean cargo-cache
234+
cargo-cache
235+
200236

201237
fmt:
202238
name: Rustfmt

0 commit comments

Comments
 (0)