mirror of
https://github.com/ludeeus/action-shellcheck.git
synced 2024-08-16 10:09:53 +02:00
feat: add format input and a single-line problem matcher (#40)
Co-authored-by: Joakim Sørensen <ludeeus@gmail.com>
This commit is contained in:
parent
184a772465
commit
94e0aab03c
4 changed files with 45 additions and 5 deletions
18
.github/problem-matcher-gcc.json
vendored
Normal file
18
.github/problem-matcher-gcc.json
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "shellcheck-gcc",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(.+):(\\d+):(\\d+):\\s(note|warning|error):\\s(.*)\\s\\[(SC\\d+)\\]$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"severity": 4,
|
||||
"message": 5,
|
||||
"code": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "shellcheck",
|
||||
"owner": "shellcheck-tty",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^In\\s(.+)\\sline\\s(\\d+):$",
|
16
README.md
16
README.md
|
@ -131,3 +131,19 @@ by setting `disable_matcher` to `true`.
|
|||
with:
|
||||
disable_matcher: true
|
||||
```
|
||||
|
||||
## Change output format
|
||||
|
||||
Shellcheck can print output in these formats: `checkstyle`, `diff`, `gcc`, `json`, `json1`, `quiet`, `tty`. See some examples [here](https://github.com/koalaman/shellcheck/wiki/Integration#pick-the-output-format-that-makes-your-life-easier).
|
||||
Only `tty` and `gcc` produce file annotations via problem matcher, default is `gcc`.
|
||||
|
||||
- `tty` has multi-line log messages, but all annotations are reported as errors
|
||||
- `gcc` has single-line log messages, so it's easier to parse with a problem matcher (including correct severity annotation)
|
||||
|
||||
```yaml
|
||||
...
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
with:
|
||||
format: tty
|
||||
```
|
||||
|
|
10
action.yaml
10
action.yaml
|
@ -26,6 +26,10 @@ inputs:
|
|||
description: "Set to true to skip using problem-matcher"
|
||||
required: false
|
||||
default: "false"
|
||||
format:
|
||||
description: "Output format (checkstyle, diff, gcc, json, json1, quiet, tty)"
|
||||
required: false
|
||||
default: "gcc"
|
||||
outputs:
|
||||
files:
|
||||
description: A list of files with issues
|
||||
|
@ -42,8 +46,9 @@ runs:
|
|||
- name: Enable problem-matcher
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ ${{ inputs.disable_matcher }} != "true" ]]; then
|
||||
echo "::add-matcher::${{ github.action_path }}/.github/problem-matcher.json"
|
||||
problem_matcher_file="${{ github.action_path }}/.github/problem-matcher-${{ inputs.format }}.json"
|
||||
if [[ ${{ inputs.disable_matcher }} != "true" && -f "$problem_matcher_file" ]]; then
|
||||
echo "::add-matcher::$problem_matcher_file"
|
||||
fi
|
||||
|
||||
- name: Download shellcheck
|
||||
|
@ -78,6 +83,7 @@ runs:
|
|||
if [[ -n "${{ inputs.severity }}" ]]; then
|
||||
options+=("-S ${{ inputs.severity }}")
|
||||
fi
|
||||
options+=("--format=${{ inputs.format }}")
|
||||
echo "::set-output name=options::${options[@]}"
|
||||
|
||||
- name: Gather excluded paths
|
||||
|
|
Loading…
Reference in a new issue