@@ -396,73 +396,61 @@ tasks:
396
396
cmds :
397
397
- poetry run flake8 --show-source
398
398
399
+ # Parameter variables:
400
+ # - SCRIPT_PATH: path of the script to be checked.
399
401
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-shell-task/Taskfile.yml
400
402
shell:check :
401
403
desc : Check for problems with shell scripts
402
404
cmds :
405
+ - |
406
+ if [[ "{{.SCRIPT_PATH}}" == "" ]]; then
407
+ echo "Path to script file must be passed to this task via the SCRIPT_PATH taskfile variable."
408
+ echo "See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-shell-task.md#usage"
409
+ exit 1
410
+ fi
403
411
- |
404
412
if ! which shellcheck &>/dev/null; then
405
413
echo "shellcheck not installed or not in PATH. Please install: https://github.com/koalaman/shellcheck#installing"
406
414
exit 1
407
415
fi
408
416
- |
409
- # There is something odd about shellcheck that causes the task to always exit on the first fail, despite any
410
- # measures that would prevent this with any other command. So it's necessary to call shellcheck only once with
411
- # the list of script paths as an argument. This could lead to exceeding the maximum command length on Windows if
412
- # the repository contained a large number of scripts, but it's unlikely to happen in reality.
413
417
shellcheck \
414
418
--format={{default "tty" .SHELLCHECK_FORMAT}} \
415
- $(
416
- # The odd method for escaping . in the regex is required for windows compatibility because mvdan.cc/sh gives
417
- # \ characters special treatment on Windows in an attempt to support them as path separators.
418
- find . \
419
- -path ".git" -prune -or \
420
- \( \
421
- -regextype posix-extended \
422
- -regex '.*[.](bash|sh)' -and \
423
- -type f \
424
- \)
425
- )
419
+ "{{.SCRIPT_PATH}}"
426
420
421
+ # Parameter variables:
422
+ # - SCRIPT_PATH: path of the script to be checked.
427
423
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-shell-task/Taskfile.yml
428
424
shell:check-mode :
429
425
desc : Check for non-executable shell scripts
430
426
cmds :
431
427
- |
432
- EXIT_STATUS=0
433
- while read -r nonExecutableScriptPath; do
434
- # The while loop always runs once, even if no file was found
435
- if [[ "$nonExecutableScriptPath" == "" ]]; then
436
- continue
437
- fi
438
-
439
- echo "::error file=${nonExecutableScriptPath}::non-executable script file: $nonExecutableScriptPath";
440
- EXIT_STATUS=1
441
- done <<<"$(
442
- # The odd approach to escaping `.` in the regex is required for windows compatibility because mvdan.cc/sh
443
- # gives `\` characters special treatment on Windows in an attempt to support them as path separators.
444
- find . \
445
- -path ".git" -prune -or \
446
- \( \
447
- -regextype posix-extended \
448
- -regex '.*[.](bash|sh)' -and \
449
- -type f -and \
450
- -not -executable \
451
- -print \
452
- \)
453
- )"
454
- exit $EXIT_STATUS
428
+ if [[ "{{.SCRIPT_PATH}}" == "" ]]; then
429
+ echo "Path to script file must be passed to this task via the SCRIPT_PATH taskfile variable."
430
+ echo "See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-shell-task.md#usage"
431
+ exit 1
432
+ fi
433
+ - |
434
+ test -x "{{.SCRIPT_PATH}}"
455
435
436
+ # Parameter variables:
437
+ # - SCRIPT_PATH: path of the script to be formatted.
456
438
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-shell-task/Taskfile.yml
457
439
shell:format :
458
440
desc : Format shell script files
459
441
cmds :
442
+ - |
443
+ if [[ "{{.SCRIPT_PATH}}" == "" ]]; then
444
+ echo "Path to script file must be passed to this task via the SCRIPT_PATH taskfile variable."
445
+ echo "See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-shell-task.md#usage"
446
+ exit 1
447
+ fi
460
448
- |
461
449
if ! which shfmt &>/dev/null; then
462
450
echo "shfmt not installed or not in PATH. Please install: https://github.com/mvdan/sh#shfmt"
463
451
exit 1
464
452
fi
465
- - shfmt -w .
453
+ - shfmt -w "{{.SCRIPT_PATH}}"
466
454
467
455
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-mkdocs-task/Taskfile.yml
468
456
website:check :
0 commit comments