@@ -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,37 @@ 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 lock_file = $action_path | path join 'uv.lock'
265
+ let key = (
266
+ if ($lock_file | path exists) {
267
+ open $lock_file --raw | hash sha256
268
+ } else {
269
+ let action_file = $action_path | path join 'action.yml'
270
+ open $action_file --raw | hash sha256
271
+ }
272
+ )
273
+ $'key=($key)\n' | save --append $env.GITHUB_OUTPUT
274
+
275
+ - name : Enable cache
276
+ if : inputs.cache == 'true' || inputs.cache == true
277
+ uses : actions/cache@v4
278
+ with :
279
+ path : ${{ runner.temp }}/cpp-linter-action-cache
280
+ key : cpp-linter-action_${{ steps.compute-cache-key.outputs.key }}
281
+
247
282
- name : Install MacOS clang dependencies
248
283
if : runner.os == 'macOS'
249
284
shell : bash
@@ -253,11 +288,6 @@ runs:
253
288
ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-format" "/usr/local/bin/clang-format-${{ inputs.version }}"
254
289
ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-tidy" "/usr/local/bin/clang-tidy-${{ inputs.version }}"
255
290
256
- - name : Setup nu shell
257
- uses : hustcer/setup-nu@v3
258
- with :
259
- version : ' 0.106.1'
260
-
261
291
- name : Setup cpp-linter dependencies
262
292
shell : nu {0}
263
293
env :
@@ -266,6 +296,7 @@ runs:
266
296
let action_path = $env.GITHUB_ACTION_PATH | str trim --right --char '/'
267
297
$env.UV_INSTALL_DIR = $action_path | path join 'bin'
268
298
$env.UV_PROJECT_ENVIRONMENT = $action_path | path join '.venv'
299
+ $env.UV_CACHE_DIR = ${{ runner.temp }} | path join 'cpp-linter-action-cache'
269
300
270
301
if ((sys host | get 'name') == 'Windows') {
271
302
^powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/0.8.9/install.ps1 | iex"
@@ -286,6 +317,7 @@ runs:
286
317
)
287
318
$env.UV_INSTALL_DIR = $action_path | path join 'bin'
288
319
$env.UV_PROJECT_ENVIRONMENT = $action_path | path join '.venv'
320
+ $env.UV_CACHE_DIR = ${{ runner.temp }} | path join 'cpp-linter-action-cache'
289
321
290
322
let args = [
291
323
--style="${{ inputs.style }}"
0 commit comments