Skip to content

Commit

Permalink
Split ignore into ignore_paths and ignore_names (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Nov 14, 2021
1 parent 2e033fa commit c2b45dd
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/additional_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
id: check
with:
additional_files: run finish discovery
ignore: ignore
ignore_paths: ignore
scandir: testfiles

- name: Verify check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_together.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: ./
id: check
with:
ignore: ignore
ignore_paths: ignore
check_together: true

- name: Verify check
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/ignore_names.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: 'base'
name: 'ignore_paths'

on:
push:
branches: ["master"]
pull_request:

jobs:
base:
name: base
ignore_paths:
name: ignore_paths
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -22,7 +22,7 @@ jobs:
uses: ./
id: check
with:
ignore: ignore
ignore_paths: ignore

- name: Verify check
run: |
Expand All @@ -35,4 +35,4 @@ jobs:
elif [[ "${{ steps.check.outputs.files }}" =~ $notexpect ]];then
echo "::error:: Expected file $notexpect found in ${{ steps.check.outputs.files }}"
exit 1
fi
fi
2 changes: 1 addition & 1 deletion .github/workflows/scandir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
id: two
with:
scandir: './testfiles/scandir'
ignore: ignore
ignore_paths: ignore

- name: Verify check
run: |
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down
30 changes: 26 additions & 4 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -98,10 +106,24 @@ runs:
excludes+=("! -path \"*./.git/*\"")
excludes+=("! -path \"*.go\"")
excludes+=("! -path \"*/mvnw\"")
for path in ${{ inputs.ignore }}; do
echo "::debug:: Adding "$path" to excludes"
excludes+=("! -path \"*./$path/*\"")
excludes+=("! -path \"*/$path/*\"")
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[@]}"
Expand Down
4 changes: 4 additions & 0 deletions testfiles/ignore_single_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/sh

test="test"
echo "$test"

0 comments on commit c2b45dd

Please sign in to comment.