mirror of
https://github.com/ludeeus/action-shellcheck.git
synced 2025-09-16 21:26:27 +02:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2f2aa0d97f | ||
![]() |
c79c26d324 | ||
![]() |
35d6c4c933 | ||
![]() |
142c6d53df | ||
![]() |
06cf1c7f5d | ||
![]() |
513f424cc7 | ||
![]() |
fbd26dc426 |
@@ -1,5 +1,5 @@
|
|||||||
on: push
|
on: [push, pull_request]
|
||||||
name: 'Trigger: Push'
|
name: 'ShellCheck'
|
||||||
jobs:
|
jobs:
|
||||||
shellcheck:
|
shellcheck:
|
||||||
name: ShellCheck
|
name: ShellCheck
|
@@ -1,6 +1,6 @@
|
|||||||
FROM alpine:3.11.6
|
FROM alpine:3.12.0
|
||||||
|
|
||||||
RUN apk add --no-cache shellcheck bash
|
RUN apk add --no-cache shellcheck bash
|
||||||
|
|
||||||
COPY runaction.sh /action/runaction.sh
|
COPY runaction /action/runaction
|
||||||
ENTRYPOINT ["bash", "/action/runaction.sh"]
|
ENTRYPOINT ["bash", "/action/runaction"]
|
30
README.md
30
README.md
@@ -57,3 +57,33 @@ example:
|
|||||||
```
|
```
|
||||||
|
|
||||||
This will skip `sample/directory/with/files/toignore/test.sh`
|
This will skip `sample/directory/with/files/toignore/test.sh`
|
||||||
|
|
||||||
|
## Minimum severity of errors to consider (error, warning, info, style)
|
||||||
|
|
||||||
|
You can use the `severity` input to not fail until specified severity is met, for example fail only if there are errors in scripts but ignore styling, info and warnings.
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
...
|
||||||
|
- name: Run ShellCheck
|
||||||
|
uses: ludeeus/action-shellcheck@master
|
||||||
|
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.
|
||||||
|
@@ -6,6 +6,14 @@ inputs:
|
|||||||
description: 'Paths to ignore when running ShellCheck'
|
description: 'Paths to ignore when running ShellCheck'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
severity:
|
||||||
|
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:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'Dockerfile'
|
image: 'Dockerfile'
|
||||||
|
@@ -10,13 +10,16 @@ declare -a tmp
|
|||||||
statuscode=0
|
statuscode=0
|
||||||
|
|
||||||
excludes+=( ! -path *./.git/* )
|
excludes+=( ! -path *./.git/* )
|
||||||
|
excludes+=( ! -path *.go )
|
||||||
|
excludes+=( ! -path */mvnw )
|
||||||
|
|
||||||
for path in ${INPUT_IGNORE}; do
|
for path in ${INPUT_IGNORE}; do
|
||||||
echo "::debug:: Adding '${path}' to excludes"
|
echo "::debug:: Adding '${path}' to excludes"
|
||||||
excludes+=(! -path "*./${path}/*" )
|
excludes+=(! -path "*./${path}/*" )
|
||||||
excludes+=(! -path "*/${path}/*" )
|
excludes+=(! -path "*/${path}/*" )
|
||||||
done
|
done
|
||||||
|
|
||||||
readarray -d '' filepaths < <(find . "${excludes[@]}" \
|
readarray -d '' filepaths < <(find . -type f "${excludes[@]}" \
|
||||||
'(' \
|
'(' \
|
||||||
\
|
\
|
||||||
-name '*.bash' \
|
-name '*.bash' \
|
||||||
@@ -38,7 +41,6 @@ readarray -d '' filepaths < <(find . "${excludes[@]}" \
|
|||||||
-o -path '*/zsh*' \
|
-o -path '*/zsh*' \
|
||||||
-o -name '*.sh' \
|
-o -name '*.sh' \
|
||||||
-o -path '*/.profile*' \
|
-o -path '*/.profile*' \
|
||||||
-o -path '*/profile*' \
|
|
||||||
-o -path '*/.shlib*' \
|
-o -path '*/.shlib*' \
|
||||||
-o -path '*/shlib*' \
|
-o -path '*/shlib*' \
|
||||||
')'\
|
')'\
|
||||||
@@ -64,9 +66,17 @@ then
|
|||||||
echo >&2 "::warning:: programs in PATH should not have a filename suffix"
|
echo >&2 "::warning:: programs in PATH should not have a filename suffix"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[[ -n "${INPUT_SEVERITY}" ]] && options+=(-S "${INPUT_SEVERITY}")
|
||||||
|
|
||||||
|
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
|
for file in "${filepaths[@]}"; do
|
||||||
echo "::debug:: Checking $file"
|
echo "::debug:: Checking $file"
|
||||||
shellcheck "$file" || statuscode=$?
|
shellcheck "${options[@]}" "$file" || statuscode=$?
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
exit "$statuscode"
|
exit "$statuscode"
|
Reference in New Issue
Block a user