Skip to content

Commit 9644e9e

Browse files
authored
Merge pull request #19 from WalletConnect/feat/restore_and_save_cache
feat: restore and save cache as options, updating the checkout version
2 parents 6d5dedf + 210b501 commit 9644e9e

File tree

10 files changed

+128
-33
lines changed

10 files changed

+128
-33
lines changed

.github/workflows/build-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
runs-on: ${{ inputs.run-label }}
3636
steps:
3737
- name: Checkout
38-
uses: actions/checkout@v5
38+
uses: actions/checkout@v6
3939
with:
4040
fetch-depth: 0
4141
ref: ${{ inputs.version }}

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

Lines changed: 94 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ on:
5151
description: 'The run label to use for the actions'
5252
type: string
5353
default: 'ubuntu-latest'
54+
rust-cache-prefix:
55+
description: 'Prefix for Rust cache key (bump to invalidate all caches)'
56+
type: string
57+
default: 'v0-rust'
58+
rust-cache-save:
59+
description: 'Whether to save the Rust cache (set to false for PRs to only restore from main)'
60+
type: boolean
61+
default: true
5462

5563
env:
5664
RUST_BACKTRACE: ${{ inputs.rust-backtrace }}
@@ -64,7 +72,7 @@ jobs:
6472
runs-on: ${{ inputs.run-label }}
6573
steps:
6674
- name: Checkout
67-
uses: actions/checkout@v5
75+
uses: actions/checkout@v6
6876
with:
6977
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
7078
submodules: recursive
@@ -77,15 +85,17 @@ jobs:
7785
components: 'cargo,clippy'
7886
override: true
7987

80-
- name: Cache Cargo registry
81-
uses: actions/cache@v4
88+
- name: Restore Cargo cache
89+
uses: actions/cache/restore@v4
8290
with:
8391
path: |
8492
~/.cargo/bin/
8593
~/.cargo/registry/
8694
~/.cargo/git/
8795
target/
88-
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
96+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
97+
restore-keys: |
98+
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-clippy-
8999
90100
- name: Install Protoc
91101
if: ${{ inputs.install-protoc == true }}
@@ -103,12 +113,23 @@ jobs:
103113
command: clippy
104114
args: --workspace --all-features --all-targets -- -D warnings
105115

116+
- name: Save Cargo cache
117+
if: ${{ inputs.rust-cache-save }}
118+
uses: actions/cache/save@v4
119+
with:
120+
path: |
121+
~/.cargo/bin/
122+
~/.cargo/registry/
123+
~/.cargo/git/
124+
target/
125+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
126+
106127
formatting:
107128
name: Formatting
108129
runs-on: ${{ inputs.run-label }}
109130
steps:
110131
- name: Checkout
111-
uses: actions/checkout@v5
132+
uses: actions/checkout@v6
112133
with:
113134
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
114135
submodules: recursive
@@ -119,15 +140,17 @@ jobs:
119140
profile: 'default'
120141
override: true
121142

122-
- name: Cache Cargo registry
123-
uses: actions/cache@v4
143+
- name: Restore Cargo cache
144+
uses: actions/cache/restore@v4
124145
with:
125146
path: |
126147
~/.cargo/bin/
127148
~/.cargo/registry/
128149
~/.cargo/git/
129150
target/
130-
key: ${{ runner.os }}-cargo-formatting-${{ hashFiles('**/Cargo.lock') }}
151+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-formatting-${{ hashFiles('**/Cargo.lock') }}
152+
restore-keys: |
153+
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-formatting-
131154
132155
- name: Run sccache-cache
133156
if: ${{ inputs.use-sccache == true }}
@@ -139,12 +162,23 @@ jobs:
139162
command: fmt
140163
args: -- --check
141164

165+
- name: Save Cargo cache
166+
if: ${{ inputs.rust-cache-save }}
167+
uses: actions/cache/save@v4
168+
with:
169+
path: |
170+
~/.cargo/bin/
171+
~/.cargo/registry/
172+
~/.cargo/git/
173+
target/
174+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-formatting-${{ hashFiles('**/Cargo.lock') }}
175+
142176
tests:
143177
name: Unit Tests
144178
runs-on: ${{ inputs.run-label }}
145179
steps:
146180
- name: Checkout
147-
uses: actions/checkout@v5
181+
uses: actions/checkout@v6
148182
with:
149183
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
150184
submodules: recursive
@@ -156,15 +190,17 @@ jobs:
156190
profile: 'default'
157191
override: true
158192

159-
- name: Cache Cargo registry
160-
uses: actions/cache@v4
193+
- name: Restore Cargo cache
194+
uses: actions/cache/restore@v4
161195
with:
162196
path: |
163197
~/.cargo/bin/
164198
~/.cargo/registry/
165199
~/.cargo/git/
166200
target/
167-
key: ${{ runner.os }}-cargo-tests-${{ hashFiles('**/Cargo.lock') }}
201+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-${{ hashFiles('**/Cargo.lock') }}
202+
restore-keys: |
203+
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-
168204
169205
- name: Install Protoc
170206
if: ${{ inputs.install-protoc == true }}
@@ -182,6 +218,17 @@ jobs:
182218
command: test
183219
args: ${{ inputs.test-args }}
184220

221+
- name: Save Cargo cache
222+
if: ${{ inputs.rust-cache-save }}
223+
uses: actions/cache/save@v4
224+
with:
225+
path: |
226+
~/.cargo/bin/
227+
~/.cargo/registry/
228+
~/.cargo/git/
229+
target/
230+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-${{ hashFiles('**/Cargo.lock') }}
231+
185232
tests-suites:
186233
name: Tests Suite "${{ matrix.element }}"
187234
if: (inputs.test-suites != '') && (inputs.test-suites != '[]')
@@ -192,7 +239,7 @@ jobs:
192239
runs-on: ${{ inputs.run-label }}
193240
steps:
194241
- name: Checkout
195-
uses: actions/checkout@v5
242+
uses: actions/checkout@v6
196243
with:
197244
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
198245
submodules: recursive
@@ -212,15 +259,17 @@ jobs:
212259
profile: 'default'
213260
override: true
214261

215-
- name: Cache Cargo registry
216-
uses: actions/cache@v4
262+
- name: Restore Cargo cache
263+
uses: actions/cache/restore@v4
217264
with:
218265
path: |
219266
~/.cargo/bin/
220267
~/.cargo/registry/
221268
~/.cargo/git/
222269
target/
223-
key: ${{ runner.os }}-cargo-tests-suites-${{ hashFiles('**/Cargo.lock') }}
270+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-suites-${{ hashFiles('**/Cargo.lock') }}
271+
restore-keys: |
272+
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-suites-
224273
225274
- name: Install Protoc
226275
if: ${{ inputs.install-protoc == true }}
@@ -238,13 +287,24 @@ jobs:
238287
command: test
239288
args: --test ${{ matrix.element }}
240289

290+
- name: Save Cargo cache
291+
if: ${{ inputs.rust-cache-save }}
292+
uses: actions/cache/save@v4
293+
with:
294+
path: |
295+
~/.cargo/bin/
296+
~/.cargo/registry/
297+
~/.cargo/git/
298+
target/
299+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-tests-suites-${{ hashFiles('**/Cargo.lock') }}
300+
241301
unused-dependencies:
242302
name: Unused Dependencies
243303
runs-on: ${{ inputs.run-label }}
244304
if: ${{ inputs.check-udeps }}
245305
steps:
246306
- name: Checkout
247-
uses: actions/checkout@v5
307+
uses: actions/checkout@v6
248308
with:
249309
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
250310
submodules: recursive
@@ -256,15 +316,17 @@ jobs:
256316
profile: 'default'
257317
override: true
258318

259-
- name: Cache Cargo registry
260-
uses: actions/cache@v4
319+
- name: Restore Cargo cache
320+
uses: actions/cache/restore@v4
261321
with:
262322
path: |
263323
~/.cargo/bin/
264324
~/.cargo/registry/
265325
~/.cargo/git/
266326
target/
267-
key: ${{ runner.os }}-cargo-unused-deps-${{ hashFiles('**/Cargo.lock') }}
327+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-unused-deps-${{ hashFiles('**/Cargo.lock') }}
328+
restore-keys: |
329+
${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-unused-deps-
268330
269331
- name: Run sccache-cache
270332
if: ${{ inputs.use-sccache == true }}
@@ -276,11 +338,22 @@ jobs:
276338
version: 'v0.1.43'
277339
args: '--all-targets'
278340

341+
- name: Save Cargo cache
342+
if: ${{ inputs.rust-cache-save }}
343+
uses: actions/cache/save@v4
344+
with:
345+
path: |
346+
~/.cargo/bin/
347+
~/.cargo/registry/
348+
~/.cargo/git/
349+
target/
350+
key: ${{ inputs.rust-cache-prefix }}-${{ runner.os }}-cargo-unused-deps-${{ hashFiles('**/Cargo.lock') }}
351+
279352
license:
280353
name: Licenses
281354
runs-on: ${{ inputs.run-label }}
282355
steps:
283-
- uses: actions/checkout@v5
356+
- uses: actions/checkout@v6
284357
with:
285358
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
286359
submodules: recursive

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
runs-on: ${{ inputs.run-label }}
3333
steps:
3434
- name: Checkout
35-
uses: actions/checkout@v5
35+
uses: actions/checkout@v6
3636
with:
3737
submodules: recursive
3838
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
@@ -51,7 +51,7 @@ jobs:
5151
runs-on: ${{ inputs.run-label }}
5252
steps:
5353
- name: Checkout
54-
uses: actions/checkout@v5
54+
uses: actions/checkout@v6
5555
with:
5656
submodules: recursive
5757
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
@@ -80,7 +80,7 @@ jobs:
8080
runs-on: ${{ inputs.run-label }}
8181
steps:
8282
- name: Checkout
83-
uses: actions/checkout@v5
83+
uses: actions/checkout@v6
8484
with:
8585
submodules: recursive
8686
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
@@ -111,7 +111,7 @@ jobs:
111111
runs-on: ${{ inputs.run-label }}
112112
steps:
113113
- name: Checkout
114-
uses: actions/checkout@v5
114+
uses: actions/checkout@v6
115115
with:
116116
submodules: recursive
117117
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}

.github/workflows/ci-plan-infra.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
url: ${{ inputs.stage-url }}
6363
steps:
6464
- name: Checkout
65-
uses: actions/checkout@v5
65+
uses: actions/checkout@v6
6666
with:
6767
submodules: recursive
6868
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}

.github/workflows/deploy-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
url: ${{ inputs.stage-url }}
5252
steps:
5353
- name: Checkout
54-
uses: actions/checkout@v5
54+
uses: actions/checkout@v6
5555
with:
5656
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
5757
submodules: recursive

.github/workflows/deploy-infra.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
url: ${{ inputs.stage-url }}
6363
steps:
6464
- name: Checkout
65-
uses: actions/checkout@v5
65+
uses: actions/checkout@v6
6666
with:
6767
submodules: recursive
6868
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}

.github/workflows/release-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ${{ inputs.run-label }}
4040
steps:
4141
- name: Checkout
42-
uses: actions/checkout@v5
42+
uses: actions/checkout@v6
4343
with:
4444
submodules: recursive
4545
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}

examples/event_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
name: Paths Filter
4141
runs-on: ubuntu-latest
4242
steps:
43-
- uses: actions/checkout@v5
43+
- uses: actions/checkout@v6
4444
with:
4545
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
4646
submodules: recursive

examples/event_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
name: Paths Filter
3434
runs-on: ubuntu-latest
3535
steps:
36-
- uses: actions/checkout@v5
36+
- uses: actions/checkout@v6
3737
with:
3838
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
3939
submodules: recursive

examples/sub-validate.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
url: ${{ inputs.stage-url }}
3636
steps:
3737
- name: Checkout
38-
uses: actions/checkout@v5
38+
uses: actions/checkout@v6
3939
with:
4040
submodules: recursive
4141
token: ${{ secrets.PRIVATE_SUBMODULE_ACCESS_TOKEN || github.token }}
@@ -47,6 +47,18 @@ jobs:
4747
profile: 'default'
4848
override: true
4949

50+
- name: Restore Cargo cache
51+
uses: actions/cache/restore@v4
52+
with:
53+
path: |
54+
~/.cargo/bin/
55+
~/.cargo/registry/
56+
~/.cargo/git/
57+
target/
58+
key: v0-rust-${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }}
59+
restore-keys: |
60+
v0-rust-${{ runner.os }}-cargo-integration-
61+
5062
- name: "Run Integration Tests"
5163
uses: WalletConnect/actions-rs/cargo@2.0.0
5264
env:
@@ -55,3 +67,13 @@ jobs:
5567
with:
5668
command: test
5769
args: --test integration
70+
71+
- name: Save Cargo cache
72+
uses: actions/cache/save@v4
73+
with:
74+
path: |
75+
~/.cargo/bin/
76+
~/.cargo/registry/
77+
~/.cargo/git/
78+
target/
79+
key: v0-rust-${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }}

0 commit comments

Comments
 (0)