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:
parent
142c6d53df
commit
35d6c4c933
3 changed files with 30 additions and 4 deletions
16
README.md
16
README.md
|
@ -71,3 +71,19 @@ example:
|
||||||
with:
|
with:
|
||||||
severity: error
|
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.
|
||||||
|
|
|
@ -10,6 +10,10 @@ inputs:
|
||||||
description: 'Minimum severity of errors to consider. Options: [error, warning, info, style]'
|
description: 'Minimum severity of errors to consider. Options: [error, warning, info, style]'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
check_together:
|
||||||
|
description: 'Run shellcheck on _all_ files at once, instead of one at a time'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'Dockerfile'
|
image: 'Dockerfile'
|
||||||
|
|
14
runaction.sh
14
runaction.sh
|
@ -68,9 +68,15 @@ fi
|
||||||
|
|
||||||
[[ -n "${INPUT_SEVERITY}" ]] && options+=(-S "${INPUT_SEVERITY}")
|
[[ -n "${INPUT_SEVERITY}" ]] && options+=(-S "${INPUT_SEVERITY}")
|
||||||
|
|
||||||
for file in "${filepaths[@]}"; do
|
if [[ -n "$INPUT_CHECK_TOGETHER" ]]; then
|
||||||
echo "::debug:: Checking $file"
|
echo "::debug:: shellcheck ${options[*]} ${filepaths[*]}"
|
||||||
shellcheck "${options[@]}" "$file" || statuscode=$?
|
shellcheck "${options[@]}" "${filepaths[@]}" || statuscode=$?
|
||||||
done
|
else
|
||||||
|
echo "::debug:: Shellcheck options: ${options[*]}"
|
||||||
|
for file in "${filepaths[@]}"; do
|
||||||
|
echo "::debug:: Checking $file"
|
||||||
|
shellcheck "${options[@]}" "$file" || statuscode=$?
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
exit "$statuscode"
|
exit "$statuscode"
|
||||||
|
|
Loading…
Reference in a new issue