Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/additional_files.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'additional_files'

on:
on:
push:
branches:
- "master"
Expand Down Expand Up @@ -32,7 +32,7 @@ jobs:
scandir: testfiles

- name: Verify check
run: |
run: |
expect="testfiles/scandir/run"

if [[ ! "${{ steps.check.outputs.files }}" =~ testfiles/scandir/run ]];then
Expand All @@ -44,4 +44,4 @@ jobs:
elif [[ ! "${{ steps.check.outputs.files }}" =~ testfiles/scandir/discovery ]];then
echo "::error:: Expected file testfiles/scandir/discovery not found in ${{ steps.check.outputs.files }}"
exit 1
fi
fi
6 changes: 3 additions & 3 deletions .github/workflows/check_together.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'check_together'

on:
on:
push:
branches:
- "master"
Expand Down Expand Up @@ -31,7 +31,7 @@ jobs:
check_together: true

- name: Verify check
run: |
run: |
expect="testfiles/test.bash"
notexpect="testfiles/ignore/ignore.bash"

Expand All @@ -41,4 +41,4 @@ jobs:
elif [[ "${{ steps.check.outputs.files }}" =~ $notexpect ]];then
echo "::error:: Expected file $notexpect found in ${{ steps.check.outputs.files }}"
exit 1
fi
fi
8 changes: 4 additions & 4 deletions .github/workflows/ignore_names.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'ignore_names'

on:
on:
push:
branches:
- "master"
Expand Down Expand Up @@ -31,14 +31,14 @@ jobs:
ignore_names: ignore_single_file.sh

- name: Verify check
run: |
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 }}"
echo "::error:: Unexpected file $notexpect found in ${{ steps.check.outputs.files }}"
exit 1
fi
fi
72 changes: 72 additions & 0 deletions .github/workflows/ignore_symlinks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: 'ignore_symlinks'

on:
push:
branches:
- "master"
pull_request:
branches:
- "master"

permissions: {}

jobs:
ignore_symlinks:
name: ignore_symlinks
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Run ShellCheck (ignore symbolic links)
uses: ./
id: check
with:
ignore_paths: ignore
ignore_symlinks: true
additional_files: symlink.sh

- name: Verify check (ignore symbolic links)
run: |
# Verify that symlink is not included
notexpect="testfiles/symlink.sh"
if [[ "${{ steps.check.outputs.files }}" =~ $notexpect ]];then
echo "::error:: Unexpected file $notexpect found in ${{ steps.check.outputs.files }}"
exit 1
fi
# Verify that ignored path is not included
notexpect="testfiles/ignore/symlink.sh"
if [[ "${{ steps.check.outputs.files }}" =~ $notexpect ]];then
echo "::error:: Unexpected file $notexpect found in ${{ steps.check.outputs.files }}"
exit 1
fi
- name: Run ShellCheck (include symbolic links)
uses: ./
id: check
with:
ignore_paths: ignore
ignore_symlinks: false
additional_files: symlink.sh

- name: Verify check (include symbolic links)
run: |
# Verify that symlink is included
expect="testfiles/symlink.sh"
if [[ ! "${{ steps.check.outputs.files }}" =~ $expect ]];then
echo "::error:: Expected file $expect not found in ${{ steps.check.outputs.files }}"
exit 1
fi
# Verify that ignored path is not included
notexpect="testfiles/ignore/symlink.sh"
if [[ "${{ steps.check.outputs.files }}" =~ $notexpect ]];then
echo "::error:: Unexpected file $notexpect found in ${{ steps.check.outputs.files }}"
exit 1
fi
18 changes: 15 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ inputs:
description: "Names to ignore when running ShellCheck"
required: false
default: ""
ignore_symlinks:
description: "Ignore files that are symbolic links."
required: false
default: "true"
severity:
description: "Minimum severity of errors to consider. Options: [error, warning, info, style]"
required: false
Expand Down Expand Up @@ -86,13 +90,17 @@ runs:
shell: bash
id: options
env:
INPUT_IGNORE_SYMLINKS: ${{ inputs.ignore_symlinks }}
INPUT_SEVERITY: ${{ inputs.severity }}
INPUT_FORMAT: ${{ inputs.format }}
run: |
declare -a options
if [[ -n "${INPUT_SEVERITY}" ]]; then
options+=("-S ${INPUT_SEVERITY}")
fi
if [[ "${INPUT_IGNORE_SYMLINKS}" != "true" ]]; then
echo "file_options=-L" >> $GITHUB_OUTPUT
fi
options+=("--format=${INPUT_FORMAT}")
echo "options=${options[@]}" >> $GITHUB_OUTPUT

Expand Down Expand Up @@ -148,7 +156,7 @@ runs:
id: check
env:
INPUT_SCANDIR: ${{ inputs.scandir }}
INPUT_CHECK_TOGETHER: ${{ inputs.check_together }}
INPUT_FILE_OPTIONS: ${{ steps.options.outputs.file_options }}
INPUT_EXCLUDE_ARGS: ${{ steps.exclude.outputs.excludes }}
INPUT_ADDITIONAL_FILE_ARGS: ${{ steps.additional.outputs.files }}
INPUT_SHELLCHECK_OPTIONS: ${{ steps.options.outputs.options }}
Expand All @@ -161,7 +169,9 @@ runs:

while IFS= read -r -d '' file; do
filepaths+=("$file")
done < <(find "${INPUT_SCANDIR}" \
done < <(find \
${INPUT_FILE_OPTIONS} \
"${INPUT_SCANDIR}" \
${INPUT_EXCLUDE_ARGS} \
-type f \
'(' \
Expand Down Expand Up @@ -198,7 +208,9 @@ runs:
while IFS= read -r -d '' file; do
head -n1 "$file" | grep -Eqs "$shebangregex" || continue
filepaths+=("$file")
done < <(find "${INPUT_SCANDIR}" \
done < <(find \
${INPUT_FILE_OPTIONS} \
"${INPUT_SCANDIR}" \
${INPUT_EXCLUDE_ARGS} \
-type f ! -name '*.*' -perm /111 \
-print0)
Expand Down
3 changes: 3 additions & 0 deletions testfiles/ignore/symlink.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
test="test"
echo "$test"
1 change: 1 addition & 0 deletions testfiles/symlink.sh