mirror of
https://github.com/ludeeus/action-shellcheck.git
synced 2025-09-16 21:26:27 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
94e0aab03c | ||
![]() |
184a772465 | ||
![]() |
f01a9171d3 | ||
![]() |
7fa8ae9d42 | ||
![]() |
f0d446b80e | ||
![]() |
00209834e5 | ||
![]() |
ac3e5d1ab4 | ||
![]() |
b247a9c05d |
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+):$",
|
||||
@@ -14,9 +14,10 @@
|
||||
{
|
||||
"regexp": "(SC\\d+):\\s(.+)$",
|
||||
"code": 1,
|
||||
"message": 2
|
||||
"message": 2,
|
||||
"loop": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
8
.github/release-drafter.yml
vendored
Normal file
8
.github/release-drafter.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
change-template: '- #$NUMBER $TITLE @$AUTHOR'
|
||||
sort-direction: ascending
|
||||
exclude-labels:
|
||||
- "release-drafter-ignore"
|
||||
template: |
|
||||
## What’s Changed
|
||||
|
||||
$CHANGES
|
16
.github/workflows/release-drafter.yml
vendored
Normal file
16
.github/workflows/release-drafter.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Release Drafter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
release-drafter:
|
||||
name: Release Drafter
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 🏃 Run Release Drafter
|
||||
uses: release-drafter/release-drafter@v5
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
34
README.md
34
README.md
@@ -22,9 +22,14 @@ jobs:
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
```
|
||||
|
||||
## Globally disable checks
|
||||
## ShellCheck options
|
||||
|
||||
To disable specific checks add it to a `SHELLCHECK_OPTS` env key in the job definition.
|
||||
You can pass any supported ShellCheck option or flag with the `SHELLCHECK_OPTS` env key in the job definition.
|
||||
|
||||
Some examples include:
|
||||
|
||||
* To disable specific checks (eg: `-e SC2059 -e SC2034 -e SC1090`)
|
||||
* To test against different shells (eg: `-s dash` or `-s ksh`)
|
||||
|
||||
example:
|
||||
|
||||
@@ -42,7 +47,8 @@ You can use the `ignore` input to disable specific directories.
|
||||
|
||||
```text
|
||||
sample structure:
|
||||
sample/directory/with/files/toignore/test.sh
|
||||
sample/directory/with/files/ignoreme/test.sh
|
||||
sample/directory/with/files/ignoremetoo/test.sh
|
||||
sample/directory/with/files/test.sh
|
||||
```
|
||||
|
||||
@@ -53,10 +59,10 @@ example:
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
with:
|
||||
ignore: toignore
|
||||
ignore: ignoreme ignoremetoo
|
||||
```
|
||||
|
||||
This will skip `sample/directory/with/files/toignore/test.sh`
|
||||
This will skip `sample/directory/with/files/ignoreme/test.sh` and `sample/directory/with/files/ignoremetoo/test.sh`
|
||||
|
||||
## Minimum severity of errors to consider (error, warning, info, style)
|
||||
|
||||
@@ -124,4 +130,20 @@ by setting `disable_matcher` to `true`.
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
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
|
||||
```
|
||||
|
23
action.yaml
23
action.yaml
@@ -3,7 +3,7 @@ author: "Ludeeus <hi@ludeeus.dev>"
|
||||
description: "GitHub action for ShellCheck."
|
||||
inputs:
|
||||
additional_files:
|
||||
description: "A space seperated list of additional filename to check"
|
||||
description: "A space separated list of additional filename to check"
|
||||
required: false
|
||||
default: ""
|
||||
ignore:
|
||||
@@ -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
|
||||
@@ -38,12 +42,13 @@ 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"
|
||||
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
|
||||
@@ -65,6 +70,11 @@ runs:
|
||||
mv "${{ github.action_path }}/shellcheck-${scversion}/shellcheck" \
|
||||
"${{ github.action_path }}/shellcheck"
|
||||
|
||||
- name: Display shellcheck version
|
||||
shell: bash
|
||||
run: |
|
||||
"${{ github.action_path }}/shellcheck" --version
|
||||
|
||||
- name: Set options
|
||||
shell: bash
|
||||
id: options
|
||||
@@ -73,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
|
||||
@@ -185,7 +196,7 @@ runs:
|
||||
"$file" || statuscode=$?;
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
echo "::set-output name=statuscode::$statuscode"
|
||||
|
||||
- name: Print information
|
||||
@@ -196,4 +207,4 @@ runs:
|
||||
echo "Options: ${{ steps.options.outputs.options }}"
|
||||
echo "Status code: ${{steps.check.outputs.statuscode}}"
|
||||
|
||||
exit ${{steps.check.outputs.statuscode}}
|
||||
exit ${{steps.check.outputs.statuscode}}
|
||||
|
Reference in New Issue
Block a user