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 | |
---|---|---|---|
![]() |
2394c9008b | ||
![]() |
637bb438ec | ||
![]() |
2f2aa0d97f | ||
![]() |
c79c26d324 | ||
![]() |
35d6c4c933 | ||
![]() |
142c6d53df | ||
![]() |
06cf1c7f5d |
22
.github/problem-matcher.json
vendored
Normal file
22
.github/problem-matcher.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "shellcheck",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^In\\s(.+)\\sline\\s(\\d+):$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"regexp": ".*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"regexp": "(SC\\d+):\\s(.+)$",
|
||||||
|
"code": 1,
|
||||||
|
"message": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -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'
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
## Enable problem matcher
|
||||||
|
|
||||||
cd "$GITHUB_WORKSPACE" || exit 1
|
cd "$GITHUB_WORKSPACE" || exit 1
|
||||||
|
|
||||||
declare statuscode
|
declare statuscode
|
||||||
@@ -19,7 +21,7 @@ for path in ${INPUT_IGNORE}; do
|
|||||||
excludes+=(! -path "*/${path}/*" )
|
excludes+=(! -path "*/${path}/*" )
|
||||||
done
|
done
|
||||||
|
|
||||||
readarray -d '' filepaths < <(find . "${excludes[@]}" \
|
readarray -d '' filepaths < <(find . -type f "${excludes[@]}" \
|
||||||
'(' \
|
'(' \
|
||||||
\
|
\
|
||||||
-name '*.bash' \
|
-name '*.bash' \
|
||||||
@@ -66,9 +68,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
|
||||||
|
|
||||||
for file in "${filepaths[@]}"; do
|
[[ -n "${INPUT_SEVERITY}" ]] && options+=(-S "${INPUT_SEVERITY}")
|
||||||
echo "::debug:: Checking $file"
|
|
||||||
shellcheck "$file" || statuscode=$?
|
if [[ -n "$INPUT_CHECK_TOGETHER" ]]; then
|
||||||
done
|
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"
|
exit "$statuscode"
|
@@ -1,3 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
echo $test
|
echo $test $test
|
||||||
|
|
||||||
|
echo $test2
|
Reference in New Issue
Block a user