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
5563env :
5664 RUST_BACKTRACE : ${{ inputs.rust-backtrace }}
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
0 commit comments