1
0
Fork 0
mirror of https://github.com/ludeeus/action-shellcheck.git synced 2024-08-16 10:09:53 +02:00

Add the ability to check all scripts in one shellcheck command (#17)

This is the most straightforward way to allow sourcing scripts, as shellcheck
[SC1090] only allows `source` files that are in the same invocation, I believe
unless `-x` is also specified.

[SC1090]: https://github.com/koalaman/shellcheck/wiki/SC1090
This commit is contained in:
Brandon W Maister 2020-06-26 15:41:45 -04:00 committed by GitHub
parent 142c6d53df
commit 35d6c4c933
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 4 deletions

View file

@ -71,3 +71,19 @@ example:
with:
severity: error
```
## Run shellcheck with all paths in a single invocation
If you run into SC1090/SC1091 errors you may need to tell shellcheck to check
all files at once:
```yaml
...
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
check_together: 'yes'
```
This can turn into a problem if you have enough script files to overwhelm the
maximum argv length on your system.

View file

@ -10,6 +10,10 @@ inputs:
description: 'Minimum severity of errors to consider. Options: [error, warning, info, style]'
required: false
default: ''
check_together:
description: 'Run shellcheck on _all_ files at once, instead of one at a time'
required: false
default: ''
runs:
using: 'docker'
image: 'Dockerfile'

View file

@ -68,9 +68,15 @@ fi
[[ -n "${INPUT_SEVERITY}" ]] && options+=(-S "${INPUT_SEVERITY}")
for file in "${filepaths[@]}"; do
echo "::debug:: Checking $file"
shellcheck "${options[@]}" "$file" || statuscode=$?
done
if [[ -n "$INPUT_CHECK_TOGETHER" ]]; then
echo "::debug:: shellcheck ${options[*]} ${filepaths[*]}"
shellcheck "${options[@]}" "${filepaths[@]}" || statuscode=$?
else
echo "::debug:: Shellcheck options: ${options[*]}"
for file in "${filepaths[@]}"; do
echo "::debug:: Checking $file"
shellcheck "${options[@]}" "$file" || statuscode=$?
done
fi
exit "$statuscode"