mirror of
https://github.com/ludeeus/action-shellcheck.git
synced 2025-01-18 17:41:58 +01:00
Split ignore into ignore_paths and ignore_names (#52)
This commit is contained in:
parent
2e033faa4a
commit
c2b45ddc5f
2
.github/workflows/additional_files.yml
vendored
2
.github/workflows/additional_files.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
|||||||
id: check
|
id: check
|
||||||
with:
|
with:
|
||||||
additional_files: run finish discovery
|
additional_files: run finish discovery
|
||||||
ignore: ignore
|
ignore_paths: ignore
|
||||||
scandir: testfiles
|
scandir: testfiles
|
||||||
|
|
||||||
- name: Verify check
|
- name: Verify check
|
||||||
|
2
.github/workflows/check_together.yml
vendored
2
.github/workflows/check_together.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
id: check
|
id: check
|
||||||
with:
|
with:
|
||||||
ignore: ignore
|
ignore_paths: ignore
|
||||||
check_together: true
|
check_together: true
|
||||||
|
|
||||||
- name: Verify check
|
- name: Verify check
|
||||||
|
41
.github/workflows/ignore_names.yml
vendored
Normal file
41
.github/workflows/ignore_names.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
name: 'ignore_names'
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["master"]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ignore_names:
|
||||||
|
name: ignore_names
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Run ShellCheck
|
||||||
|
uses: ./
|
||||||
|
id: check
|
||||||
|
with:
|
||||||
|
ignore_paths: ignore
|
||||||
|
ignore_names: ignore_single_file.sh
|
||||||
|
|
||||||
|
- name: Verify check
|
||||||
|
run: |
|
||||||
|
expect="testfiles/test.bash"
|
||||||
|
notexpect="testfiles/ignore_single_file.sh"
|
||||||
|
|
||||||
|
if [[ ! "${{ steps.check.outputs.files }}" =~ $expect ]];then
|
||||||
|
echo "::error:: Expected file $expect not found in ${{ steps.check.outputs.files }}"
|
||||||
|
exit 1
|
||||||
|
elif [[ "${{ steps.check.outputs.files }}" =~ $notexpect ]];then
|
||||||
|
echo "::error:: Expected file $notexpect found in ${{ steps.check.outputs.files }}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
name: 'base'
|
name: 'ignore_paths'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -6,8 +6,8 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
base:
|
ignore_paths:
|
||||||
name: base
|
name: ignore_paths
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@ -22,7 +22,7 @@ jobs:
|
|||||||
uses: ./
|
uses: ./
|
||||||
id: check
|
id: check
|
||||||
with:
|
with:
|
||||||
ignore: ignore
|
ignore_paths: ignore
|
||||||
|
|
||||||
- name: Verify check
|
- name: Verify check
|
||||||
run: |
|
run: |
|
2
.github/workflows/scandir.yml
vendored
2
.github/workflows/scandir.yml
vendored
@ -42,7 +42,7 @@ jobs:
|
|||||||
id: two
|
id: two
|
||||||
with:
|
with:
|
||||||
scandir: './testfiles/scandir'
|
scandir: './testfiles/scandir'
|
||||||
ignore: ignore
|
ignore_paths: ignore
|
||||||
|
|
||||||
- name: Verify check
|
- name: Verify check
|
||||||
run: |
|
run: |
|
||||||
|
10
README.md
10
README.md
@ -41,15 +41,16 @@ example:
|
|||||||
SHELLCHECK_OPTS: -e SC2059 -e SC2034 -e SC1090
|
SHELLCHECK_OPTS: -e SC2059 -e SC2034 -e SC1090
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ignore paths
|
## Ignore paths and names
|
||||||
|
|
||||||
You can use the `ignore` input to disable specific directories.
|
You can use the `ignore_paths` and `ignore_names` input to disable specific directories and files.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
sample structure:
|
sample structure:
|
||||||
sample/directory/with/files/ignoreme/test.sh
|
sample/directory/with/files/ignoreme/test.sh
|
||||||
sample/directory/with/files/ignoremetoo/test.sh
|
sample/directory/with/files/ignoremetoo/test.sh
|
||||||
sample/directory/with/files/test.sh
|
sample/directory/with/files/test.sh
|
||||||
|
sample/directory/with/files/ignorable.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
example:
|
example:
|
||||||
@ -59,10 +60,11 @@ example:
|
|||||||
- name: Run ShellCheck
|
- name: Run ShellCheck
|
||||||
uses: ludeeus/action-shellcheck@master
|
uses: ludeeus/action-shellcheck@master
|
||||||
with:
|
with:
|
||||||
ignore: ignoreme ignoremetoo
|
ignore_paths: ignoreme ignoremetoo
|
||||||
|
ignore_names: ignorable.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
This will skip `sample/directory/with/files/ignoreme/test.sh` and `sample/directory/with/files/ignoremetoo/test.sh`
|
This will skip `sample/directory/with/files/ignoreme/test.sh`, `sample/directory/with/files/ignoremetoo/test.sh` and `sample/directory/with/files/ignorable.sh`.
|
||||||
|
|
||||||
## Minimum severity of errors to consider (error, warning, info, style)
|
## Minimum severity of errors to consider (error, warning, info, style)
|
||||||
|
|
||||||
|
30
action.yaml
30
action.yaml
@ -10,6 +10,14 @@ inputs:
|
|||||||
description: "Paths to ignore when running ShellCheck"
|
description: "Paths to ignore when running ShellCheck"
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
ignore_paths:
|
||||||
|
description: "Paths to ignore when running ShellCheck"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
ignore_names:
|
||||||
|
description: "Names to ignore when running ShellCheck"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
severity:
|
severity:
|
||||||
description: "Minimum severity of errors to consider. Options: [error, warning, info, style]"
|
description: "Minimum severity of errors to consider. Options: [error, warning, info, style]"
|
||||||
required: false
|
required: false
|
||||||
@ -98,10 +106,24 @@ runs:
|
|||||||
excludes+=("! -path \"*./.git/*\"")
|
excludes+=("! -path \"*./.git/*\"")
|
||||||
excludes+=("! -path \"*.go\"")
|
excludes+=("! -path \"*.go\"")
|
||||||
excludes+=("! -path \"*/mvnw\"")
|
excludes+=("! -path \"*/mvnw\"")
|
||||||
for path in ${{ inputs.ignore }}; do
|
if [[ -n "${{ inputs.ignore }}" ]]; then
|
||||||
echo "::debug:: Adding "$path" to excludes"
|
echo "::warning::ignore is deprecated. Please use ignore_paths instead"
|
||||||
excludes+=("! -path \"*./$path/*\"")
|
for path in ${{ inputs.ignore }}; do
|
||||||
excludes+=("! -path \"*/$path/*\"")
|
echo "::debug:: Adding "$path" to excludes"
|
||||||
|
excludes+=("! -path \"*./$path/*\"")
|
||||||
|
excludes+=("! -path \"*/$path/*\"")
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for path in ${{ inputs.ignore_paths }}; do
|
||||||
|
echo "::debug:: Adding "$path" to excludes"
|
||||||
|
excludes+=("! -path \"*./$path/*\"")
|
||||||
|
excludes+=("! -path \"*/$path/*\"")
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
for name in ${{ inputs.ignore_names }}; do
|
||||||
|
echo "::debug:: Adding "$name" to excludes"
|
||||||
|
excludes+=("! -name $name")
|
||||||
done
|
done
|
||||||
echo "::set-output name=excludes::${excludes[@]}"
|
echo "::set-output name=excludes::${excludes[@]}"
|
||||||
|
|
||||||
|
4
testfiles/ignore_single_file.sh
Normal file
4
testfiles/ignore_single_file.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/sh
|
||||||
|
|
||||||
|
test="test"
|
||||||
|
echo "$test"
|
Loading…
x
Reference in New Issue
Block a user