From 54b76a97dad484d84154242d71464303ec5c67be Mon Sep 17 00:00:00 2001 From: Alexey Alekhin Date: Wed, 31 Mar 2021 15:53:50 +0200 Subject: [PATCH 1/6] rename problem matcher to tty --- .github/{problem-matcher.json => problem-matcher-tty.json} | 0 action.yaml | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename .github/{problem-matcher.json => problem-matcher-tty.json} (100%) diff --git a/.github/problem-matcher.json b/.github/problem-matcher-tty.json similarity index 100% rename from .github/problem-matcher.json rename to .github/problem-matcher-tty.json diff --git a/action.yaml b/action.yaml index 2bdcd67..8658806 100644 --- a/action.yaml +++ b/action.yaml @@ -38,12 +38,12 @@ branding: color: "gray-dark" runs: using: "composite" - steps: + steps: - name: Enable problem-matcher shell: bash run: | if [[ ${{ inputs.disable_matcher }} != "true" ]]; then - echo "::add-matcher::${{ github.action_path }}/.github/problem-matcher.json" + echo "::add-matcher::${{ github.action_path }}/.github/problem-matcher-tty.json" fi - name: Download shellcheck @@ -190,7 +190,7 @@ runs: "$file" || statuscode=$?; done fi - + echo "::set-output name=statuscode::$statuscode" - name: Print information From 6e43ab0271ba5b6764d2fd999a0e71e62f18d65e Mon Sep 17 00:00:00 2001 From: Alexey Alekhin Date: Wed, 31 Mar 2021 16:02:11 +0200 Subject: [PATCH 2/6] add format input --- action.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 8658806..7913b9d 100644 --- a/action.yaml +++ b/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: "tty" 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-tty.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 From fcb1542d6c2b28ed28ce23f1904c1eac31b8282a Mon Sep 17 00:00:00 2001 From: Alexey Alekhin Date: Wed, 31 Mar 2021 16:04:41 +0200 Subject: [PATCH 3/6] add gcc problem matcher --- .github/problem-matcher-gcc.json | 18 ++++++++++++++++++ .github/problem-matcher-tty.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .github/problem-matcher-gcc.json diff --git a/.github/problem-matcher-gcc.json b/.github/problem-matcher-gcc.json new file mode 100644 index 0000000..cf58ce4 --- /dev/null +++ b/.github/problem-matcher-gcc.json @@ -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 + } + ] + } + ] +} diff --git a/.github/problem-matcher-tty.json b/.github/problem-matcher-tty.json index c5b8441..378c7f5 100644 --- a/.github/problem-matcher-tty.json +++ b/.github/problem-matcher-tty.json @@ -1,7 +1,7 @@ { "problemMatcher": [ { - "owner": "shellcheck", + "owner": "shellcheck-tty", "pattern": [ { "regexp": "^In\\s(.+)\\sline\\s(\\d+):$", From 107128e5b20a0e8431ea4f73cffa9e1fdcb35efa Mon Sep 17 00:00:00 2001 From: Alexey Alekhin Date: Wed, 31 Mar 2021 16:06:38 +0200 Subject: [PATCH 4/6] set default format to gcc --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 7913b9d..d2aeee6 100644 --- a/action.yaml +++ b/action.yaml @@ -29,7 +29,7 @@ inputs: format: description: "Output format (checkstyle, diff, gcc, json, json1, quiet, tty)" required: false - default: "tty" + default: "gcc" outputs: files: description: A list of files with issues From 48707f9d9216f4f5db7100e48c2a88e54d0de5b4 Mon Sep 17 00:00:00 2001 From: Alexey Alekhin Date: Wed, 31 Mar 2021 19:23:22 +0200 Subject: [PATCH 5/6] docs --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 2209760..71da9e1 100644 --- a/README.md +++ b/README.md @@ -131,3 +131,16 @@ 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 format is `gcc` since its provides more information to the problem matcher. + +```yaml + ... + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + format: tty +``` From ee1822f0ff1ec908e49adfc6bbfcf6287e3814fe Mon Sep 17 00:00:00 2001 From: Alexey Alekhin Date: Wed, 31 Mar 2021 19:29:22 +0200 Subject: [PATCH 6/6] more details --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 71da9e1..30628d1 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,10 @@ by setting `disable_matcher` to `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 format is `gcc` since its provides more information to the problem matcher. +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 ...