mirror of
https://github.com/ludeeus/action-shellcheck.git
synced 2025-09-16 21:26:27 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2394c9008b | ||
![]() |
637bb438ec | ||
![]() |
2f2aa0d97f | ||
![]() |
c79c26d324 | ||
![]() |
35d6c4c933 | ||
![]() |
142c6d53df | ||
![]() |
06cf1c7f5d | ||
![]() |
513f424cc7 | ||
![]() |
fbd26dc426 |
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
|
||||
name: 'Trigger: Push'
|
||||
on: [push, pull_request]
|
||||
name: 'ShellCheck'
|
||||
jobs:
|
||||
shellcheck:
|
||||
name: ShellCheck
|
@@ -1,6 +1,6 @@
|
||||
FROM alpine:3.11.6
|
||||
FROM alpine:3.12.0
|
||||
|
||||
RUN apk add --no-cache shellcheck bash
|
||||
|
||||
COPY runaction.sh /action/runaction.sh
|
||||
ENTRYPOINT ["bash", "/action/runaction.sh"]
|
||||
COPY runaction /action/runaction
|
||||
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`
|
||||
|
||||
## 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'
|
||||
required: false
|
||||
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:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
## Enable problem matcher
|
||||
|
||||
cd "$GITHUB_WORKSPACE" || exit 1
|
||||
|
||||
declare statuscode
|
||||
@@ -10,13 +12,16 @@ declare -a tmp
|
||||
statuscode=0
|
||||
|
||||
excludes+=( ! -path *./.git/* )
|
||||
excludes+=( ! -path *.go )
|
||||
excludes+=( ! -path */mvnw )
|
||||
|
||||
for path in ${INPUT_IGNORE}; do
|
||||
echo "::debug:: Adding '${path}' to excludes"
|
||||
excludes+=(! -path "*./${path}/*" )
|
||||
excludes+=(! -path "*/${path}/*" )
|
||||
done
|
||||
|
||||
readarray -d '' filepaths < <(find . "${excludes[@]}" \
|
||||
readarray -d '' filepaths < <(find . -type f "${excludes[@]}" \
|
||||
'(' \
|
||||
\
|
||||
-name '*.bash' \
|
||||
@@ -38,7 +43,6 @@ readarray -d '' filepaths < <(find . "${excludes[@]}" \
|
||||
-o -path '*/zsh*' \
|
||||
-o -name '*.sh' \
|
||||
-o -path '*/.profile*' \
|
||||
-o -path '*/profile*' \
|
||||
-o -path '*/.shlib*' \
|
||||
-o -path '*/shlib*' \
|
||||
')'\
|
||||
@@ -64,9 +68,17 @@ then
|
||||
echo >&2 "::warning:: programs in PATH should not have a filename suffix"
|
||||
fi
|
||||
|
||||
for file in "${filepaths[@]}"; do
|
||||
echo "::debug:: Checking $file"
|
||||
shellcheck "$file" || statuscode=$?
|
||||
done
|
||||
[[ -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
|
||||
echo "::debug:: Checking $file"
|
||||
shellcheck "${options[@]}" "$file" || statuscode=$?
|
||||
done
|
||||
fi
|
||||
|
||||
exit "$statuscode"
|
@@ -1,3 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo $test
|
||||
echo $test $test
|
||||
|
||||
echo $test2
|
Reference in New Issue
Block a user