7 Commits
0.2.1 ... 0.4.1

Author SHA1 Message Date
Joakim Sørensen
2394c9008b Remove problem matcher
Fixes #21
2020-07-14 20:29:42 +02:00
Joakim Sørensen
637bb438ec Adds problem-matcher (#20)
* Adds problem-matcher

* Fix issue

* match as group 1

* use message

* Limit output

* remove testfile
2020-07-05 23:50:07 +02:00
ludeeus
2f2aa0d97f Update alpine to 3.12.0 2020-06-27 19:42:52 +02:00
Daniel
c79c26d324 Add filetype to find command (#19)
This fixes an error when a directory contains "bash" in the name. This
would lead to a shellcheck on a directory and crash.
2020-06-27 11:43:04 +02:00
Brandon W Maister
35d6c4c933 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
2020-06-26 21:41:45 +02:00
Ilir Bekteshi
142c6d53df Add severity input (#16)
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
2020-06-26 08:05:34 +02:00
Joakim Sørensen
06cf1c7f5d Update and rename push.yml to ShellCheck.yml 2020-06-25 12:20:30 +02:00
7 changed files with 87 additions and 15 deletions

22
.github/problem-matcher.json vendored Normal file
View 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
}
]
}
]
}

View File

@@ -1,5 +1,5 @@
on: push
name: 'Trigger: Push'
on: [push, pull_request]
name: 'ShellCheck'
jobs:
shellcheck:
name: ShellCheck

View File

@@ -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"]

View File

@@ -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.

View File

@@ -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'

View File

@@ -1,5 +1,7 @@
#!/bin/bash
## Enable problem matcher
cd "$GITHUB_WORKSPACE" || exit 1
declare statuscode
@@ -19,7 +21,7 @@ for path in ${INPUT_IGNORE}; do
excludes+=(! -path "*/${path}/*" )
done
readarray -d '' filepaths < <(find . "${excludes[@]}" \
readarray -d '' filepaths < <(find . -type f "${excludes[@]}" \
'(' \
\
-name '*.bash' \
@@ -66,9 +68,17 @@ then
echo >&2 "::warning:: programs in PATH should not have a filename suffix"
fi
for file in "${filepaths[@]}"; do
[[ -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 "$file" || statuscode=$?
done
shellcheck "${options[@]}" "$file" || statuscode=$?
done
fi
exit "$statuscode"

View File

@@ -1,3 +1,5 @@
#!/bin/sh
echo $test
echo $test $test
echo $test2