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
|
||||
with:
|
||||
additional_files: run finish discovery
|
||||
ignore: ignore
|
||||
ignore_paths: ignore
|
||||
scandir: testfiles
|
||||
|
||||
- name: Verify check
|
||||
|
2
.github/workflows/check_together.yml
vendored
2
.github/workflows/check_together.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
||||
uses: ./
|
||||
id: check
|
||||
with:
|
||||
ignore: ignore
|
||||
ignore_paths: ignore
|
||||
check_together: true
|
||||
|
||||
- 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:
|
||||
push:
|
||||
@ -6,8 +6,8 @@ on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
base:
|
||||
name: base
|
||||
ignore_paths:
|
||||
name: ignore_paths
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
@ -22,7 +22,7 @@ jobs:
|
||||
uses: ./
|
||||
id: check
|
||||
with:
|
||||
ignore: ignore
|
||||
ignore_paths: ignore
|
||||
|
||||
- name: Verify check
|
||||
run: |
|
2
.github/workflows/scandir.yml
vendored
2
.github/workflows/scandir.yml
vendored
@ -42,7 +42,7 @@ jobs:
|
||||
id: two
|
||||
with:
|
||||
scandir: './testfiles/scandir'
|
||||
ignore: ignore
|
||||
ignore_paths: ignore
|
||||
|
||||
- name: Verify check
|
||||
run: |
|
||||
|
10
README.md
10
README.md
@ -41,15 +41,16 @@ example:
|
||||
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
|
||||
sample structure:
|
||||
sample/directory/with/files/ignoreme/test.sh
|
||||
sample/directory/with/files/ignoremetoo/test.sh
|
||||
sample/directory/with/files/test.sh
|
||||
sample/directory/with/files/ignorable.sh
|
||||
```
|
||||
|
||||
example:
|
||||
@ -59,10 +60,11 @@ example:
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
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)
|
||||
|
||||
|
22
action.yaml
22
action.yaml
@ -10,6 +10,14 @@ inputs:
|
||||
description: "Paths to ignore when running ShellCheck"
|
||||
required: false
|
||||
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:
|
||||
description: "Minimum severity of errors to consider. Options: [error, warning, info, style]"
|
||||
required: false
|
||||
@ -98,11 +106,25 @@ runs:
|
||||
excludes+=("! -path \"*./.git/*\"")
|
||||
excludes+=("! -path \"*.go\"")
|
||||
excludes+=("! -path \"*/mvnw\"")
|
||||
if [[ -n "${{ inputs.ignore }}" ]]; then
|
||||
echo "::warning::ignore is deprecated. Please use ignore_paths instead"
|
||||
for path in ${{ inputs.ignore }}; do
|
||||
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
|
||||
echo "::set-output name=excludes::${excludes[@]}"
|
||||
|
||||
- name: Gather additional files
|
||||
|
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