@@ -216,6 +216,10 @@ inputs:
216
216
use the number of all available CPU cores.
217
217
required : false
218
218
default : 0
219
+ cache :
220
+ description : enable caching of cpp-linter dependencies
221
+ required : false
222
+ default : true
219
223
outputs :
220
224
checks-failed :
221
225
description : An integer that can be used as a boolean value to indicate if any checks failed by clang-tidy and clang-format.
@@ -244,6 +248,40 @@ runs:
244
248
fi
245
249
fi
246
250
251
+ - name : Setup nu shell
252
+ # I'm done writing everything twice (in bash and powershell)
253
+ # With nu shell, we use the same shell/script for all platforms
254
+ uses : hustcer/setup-nu@v3
255
+ with :
256
+ version : ' 0.106.1'
257
+
258
+ - name : Compute cache key
259
+ if : inputs.cache == 'true' || inputs.cache == true
260
+ id : compute-cache-key
261
+ shell : nu {0}
262
+ run : |-
263
+ let action_path = $env.GITHUB_ACTION_PATH | str trim --right --char '/'
264
+ let req_file = $action_path | path join 'requirements.txt'
265
+ let lock_file = $action_path | path join 'uv.lock'
266
+ let action_file = $action_path | path join 'action.yml'
267
+ let key = (
268
+ if ($lock_file | path exists) {
269
+ open $lock_file --raw | hash sha256
270
+ } else if ($req_file | path exists) {
271
+ open $req_file --raw | hash sha256
272
+ } else {
273
+ open $action_file --raw | hash sha256
274
+ }
275
+ )
276
+ $'key=($key)\n' | save --append $env.GITHUB_OUTPUT
277
+
278
+ - name : Enable cache
279
+ if : inputs.cache == 'true' || inputs.cache == true
280
+ uses : actions/cache@v4
281
+ with :
282
+ path : ${{ runner.temp }}/cpp-linter-action-cache
283
+ key : cpp-linter-action_${{ steps.compute-cache-key.outputs.key }}
284
+
247
285
- name : Install MacOS clang dependencies
248
286
if : runner.os == 'macOS'
249
287
shell : bash
@@ -253,11 +291,6 @@ runs:
253
291
ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-format" "/usr/local/bin/clang-format-${{ inputs.version }}"
254
292
ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-tidy" "/usr/local/bin/clang-tidy-${{ inputs.version }}"
255
293
256
- - name : Setup nu shell
257
- uses : hustcer/setup-nu@v3
258
- with :
259
- version : ' 0.106.1'
260
-
261
294
- name : Setup cpp-linter dependencies
262
295
shell : nu {0}
263
296
env :
@@ -267,6 +300,11 @@ runs:
267
300
$env.UV_INSTALL_DIR = $action_path | path join 'bin'
268
301
$env.UV_PROJECT_ENVIRONMENT = $action_path | path join '.venv'
269
302
303
+ $env.UV_CACHE_DIR = "${{ runner.temp }}" | path join 'cpp-linter-action-cache'
304
+ if (not ($env.UV_CACHE_DIR | path exists)) {
305
+ mkdir $env.UV_CACHE_DIR
306
+ }
307
+
270
308
if ((sys host | get 'name') == 'Windows') {
271
309
^powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/0.8.9/install.ps1 | iex"
272
310
} else {
@@ -286,6 +324,7 @@ runs:
286
324
)
287
325
$env.UV_INSTALL_DIR = $action_path | path join 'bin'
288
326
$env.UV_PROJECT_ENVIRONMENT = $action_path | path join '.venv'
327
+ $env.UV_CACHE_DIR = "${{ runner.temp }}" | path join 'cpp-linter-action-cache'
289
328
290
329
let args = [
291
330
--style="${{ inputs.style }}"
0 commit comments