@@ -217,7 +217,13 @@ inputs:
217
217
required : false
218
218
default : 0
219
219
cache-enable :
220
- description : enable caching of cpp-linter dependencies
220
+ description : |-
221
+ Controls the caching of cpp-linter dependencies.
222
+ The installed `clang-format` and `clang-tidy` tools are not cached.
223
+
224
+ By default, this is enabled.
225
+ Any cached assets are kept within the path to this action's source
226
+ (not in the runner's workspace or temp directory).
221
227
required : false
222
228
default : true
223
229
outputs :
@@ -233,21 +239,6 @@ outputs:
233
239
runs :
234
240
using : " composite"
235
241
steps :
236
- - name : Install Linux clang dependencies
237
- if : runner.os == 'Linux'
238
- shell : bash
239
- run : |
240
- sudo apt-get update
241
- # First try installing from default Ubuntu repositories before trying LLVM script
242
- if ! sudo apt-get install -y clang-format-${{ inputs.version }} clang-tidy-${{ inputs.version }}; then
243
- # This LLVM script will add the relevant LLVM PPA: https://apt.llvm.org/
244
- wget https://apt.llvm.org/llvm.sh -O ${GITHUB_ACTION_PATH%/}/llvm_install.sh
245
- chmod +x ${GITHUB_ACTION_PATH%/}/llvm_install.sh
246
- if sudo ${GITHUB_ACTION_PATH%/}/llvm_install.sh ${{ inputs.version }}; then
247
- sudo apt-get install -y clang-format-${{ inputs.version }} clang-tidy-${{ inputs.version }}
248
- fi
249
- fi
250
-
251
242
- name : Setup nu shell
252
243
# I'm done writing everything twice (in bash and powershell)
253
244
# With nu shell, we use the same shell/script for all platforms
@@ -279,14 +270,68 @@ runs:
279
270
path : ${{ runner.temp }}/cpp-linter-action-cache
280
271
key : cpp-linter-action_${{ runner.os }}_${{ steps.compute-cache-key.outputs.key }}
281
272
273
+ - name : Install Linux clang dependencies
274
+ if : runner.os == 'Linux'
275
+ shell : nu {0}
276
+ run : |
277
+ let action_path = $env.GITHUB_ACTION_PATH | path expand
278
+ let apt_install_args = [
279
+ install -y clang-format-${{ inputs.version }} clang-tidy-${{ inputs.version }}
280
+ ]
281
+ let has_sudo = not ((which 'sudo') | is-empty)
282
+
283
+ # First try installing from default Ubuntu repositories before trying LLVM script
284
+ let are_tools_present = (
285
+ if $has_sudo {
286
+ ^sudo apt-get update
287
+ ^sudo apt-get ...$apt_install_args
288
+ } else {
289
+ ^apt-get update
290
+ ^apt-get ...$apt_install_args
291
+ }
292
+ ) | complete | $in.exit_code == 0
293
+ if (not $are_tools_present) {
294
+ # This LLVM script will add the relevant LLVM PPA: https://apt.llvm.org/
295
+ (
296
+ http get --raw --redirect-mode follow https://apt.llvm.org/llvm.sh
297
+ | save $"($action_path)/llvm_install.sh"
298
+ )
299
+ ^chmod +x $"($action_path)/llvm_install.sh"
300
+
301
+ let llvm_installer_result = (
302
+ if $has_sudo {
303
+ ^sudo $"($action_path)/llvm_install.sh" ${{ inputs.version }}
304
+ } else {
305
+ ^bash $"($action_path)/llvm_install.sh" ${{ inputs.version }}
306
+ }
307
+ ) | complete
308
+ print $llvm_installer_result
309
+
310
+ if ($llvm_installer_result.exit_code == 0) {
311
+ let result = (
312
+ if $has_sudo {
313
+ ^sudo apt-get ...$apt_install_args
314
+ } else {
315
+ ^apt-get ...$apt_install_args
316
+ }
317
+ ) | complete
318
+ print $result
319
+ }
320
+ }
321
+
282
322
- name : Install MacOS clang dependencies
283
323
if : runner.os == 'macOS'
284
- shell : bash
285
- continue-on-error : true
286
- run : |
287
- brew install llvm@${{ inputs.version }}
288
- ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-format" "/usr/local/bin/clang-format-${{ inputs.version }}"
289
- ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-tidy" "/usr/local/bin/clang-tidy-${{ inputs.version }}"
324
+ shell : nu {0}
325
+ run : |-
326
+ let brew_install_arg = 'llvm@${{ inputs.version }}'
327
+ let result = (^brew install $brew_install_arg) | complete
328
+ if ($result.exit_code == 0) {
329
+ let brew_prefix = ^brew --prefix $brew_install_arg
330
+ ^ln -s $"($brew_prefix)/bin/clang-format" "/usr/local/bin/clang-format-${{ inputs.version }}"
331
+ ^ln -s $"($brew_prefix)/bin/clang-tidy" "/usr/local/bin/clang-tidy-${{ inputs.version }}"
332
+ } else {
333
+ print $result
334
+ }
290
335
291
336
- name : Setup cpp-linter dependencies
292
337
shell : nu {0}
@@ -299,29 +344,29 @@ runs:
299
344
300
345
$env.UV_CACHE_DIR = $env.RUNNER_TEMP | path join 'cpp-linter-action-cache'
301
346
if (not ($env.UV_CACHE_DIR | path exists)) {
302
- mkdir $env.UV_CACHE_DIR
347
+ mkdir $env.UV_CACHE_DIR
303
348
}
304
349
305
350
print $"\n(ansi purple)Installing uv version ($env.UV_VERSION)(ansi reset)"
306
351
let is_windows = (sys host | get 'name') == 'Windows'
307
352
let uv_installer_url = if $is_windows {
308
- $"https://astral.sh/uv/($env.UV_VERSION)/install.ps1"
353
+ $"https://astral.sh/uv/($env.UV_VERSION)/install.ps1"
309
354
} else {
310
- $"https://astral.sh/uv/($env.UV_VERSION)/install.sh"
355
+ $"https://astral.sh/uv/($env.UV_VERSION)/install.sh"
311
356
}
312
357
let installer = http get --raw --redirect-mode follow $uv_installer_url
313
358
if $is_windows {
314
- ^powershell -ExecutionPolicy ByPass $installer
359
+ ^powershell -ExecutionPolicy ByPass $installer
315
360
} else {
316
- $installer | ^sh
361
+ $installer | ^sh
317
362
}
318
363
319
364
let gh_action_debug = $env | get --optional 'ACTIONS_STEP_DEBUG'
320
365
let action_verbosity = '${{ inputs.verbosity }}' == 'debug'
321
366
let verbosity = (
322
- $action_verbosity
323
- or ($gh_action_debug == true)
324
- or ($gh_action_debug == 'true')
367
+ $action_verbosity
368
+ or ($gh_action_debug == true)
369
+ or ($gh_action_debug == 'true')
325
370
)
326
371
327
372
print $"\n(ansi purple)Installing workflow dependencies(ansi reset)"
@@ -335,7 +380,7 @@ runs:
335
380
let cmd = [clang-tools -i ${{ inputs.version }} -b]
336
381
$uv_args = [run --no-sync --project $action_path --directory (pwd)]
337
382
if $verbosity {
338
- $uv_args = $uv_args | append '-v'
383
+ $uv_args = $uv_args | append '-v'
339
384
}
340
385
^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args ...$cmd
341
386
@@ -348,39 +393,39 @@ runs:
348
393
$env.UV_CACHE_DIR = $env.RUNNER_TEMP | path join 'cpp-linter-action-cache'
349
394
350
395
let args = [
351
- --style="${{ inputs.style }}"
352
- --extensions=${{ inputs.extensions }}
353
- --tidy-checks="${{ inputs.tidy-checks }}"
354
- --repo-root=${{ inputs.repo-root }}
355
- --version=${{ inputs.version }}
356
- --verbosity=${{ inputs.verbosity }}
357
- --lines-changed-only=${{ inputs.lines-changed-only }}
358
- --files-changed-only=${{ inputs.files-changed-only }}
359
- --thread-comments=${{ inputs.thread-comments }}
360
- --no-lgtm=${{ inputs.no-lgtm }}
361
- --step-summary=${{ inputs.step-summary }}
362
- --ignore="${{ inputs.ignore }}"
363
- --ignore-tidy="${{ inputs.ignore-tidy }}"
364
- --ignore-format="${{ inputs.ignore-format }}"
365
- --database=${{ inputs.database }}
366
- --file-annotations=${{ inputs.file-annotations }}
367
- --extra-arg="${{ inputs.extra-args }}"
368
- --tidy-review="${{ inputs.tidy-review }}"
369
- --format-review="${{ inputs.format-review }}"
370
- --passive-reviews="${{ inputs.passive-reviews }}"
371
- --jobs=${{ inputs.jobs }}
396
+ --style="${{ inputs.style }}"
397
+ --extensions=${{ inputs.extensions }}
398
+ --tidy-checks="${{ inputs.tidy-checks }}"
399
+ --repo-root=${{ inputs.repo-root }}
400
+ --version=${{ inputs.version }}
401
+ --verbosity=${{ inputs.verbosity }}
402
+ --lines-changed-only=${{ inputs.lines-changed-only }}
403
+ --files-changed-only=${{ inputs.files-changed-only }}
404
+ --thread-comments=${{ inputs.thread-comments }}
405
+ --no-lgtm=${{ inputs.no-lgtm }}
406
+ --step-summary=${{ inputs.step-summary }}
407
+ --ignore="${{ inputs.ignore }}"
408
+ --ignore-tidy="${{ inputs.ignore-tidy }}"
409
+ --ignore-format="${{ inputs.ignore-format }}"
410
+ --database=${{ inputs.database }}
411
+ --file-annotations=${{ inputs.file-annotations }}
412
+ --extra-arg="${{ inputs.extra-args }}"
413
+ --tidy-review="${{ inputs.tidy-review }}"
414
+ --format-review="${{ inputs.format-review }}"
415
+ --passive-reviews="${{ inputs.passive-reviews }}"
416
+ --jobs=${{ inputs.jobs }}
372
417
]
373
418
mut uv_args = [run --no-sync --project $action_path --directory (pwd)]
374
419
375
420
let gh_action_debug = $env | get --optional 'ACTIONS_STEP_DEBUG'
376
421
let action_verbosity = '${{ inputs.verbosity }}' == 'debug'
377
422
let verbosity = (
378
- $action_verbosity
379
- or ($gh_action_debug == true)
380
- or ($gh_action_debug == 'true')
423
+ $action_verbosity
424
+ or ($gh_action_debug == true)
425
+ or ($gh_action_debug == 'true')
381
426
)
382
427
if $verbosity {
383
- $uv_args = $uv_args | append '-v'
428
+ $uv_args = $uv_args | append '-v'
384
429
}
385
430
386
431
print $"\n(ansi purple)Running cpp-linter(ansi reset)"
0 commit comments