Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint only changed files #108

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all 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
30 changes: 25 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,36 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v43

- name: "Show which files we check"
shell: bash {0}
run: |
echo "# Checked files:" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.changed-files.outputs.all_changed_files }}" | sed "s/ /\n/g" >> $GITHUB_STEP_SUMMARY

- name: Environment variables
run: sudo -E bash -c set

- name: "Shellcheck lint error report in diff format"
shell: bash {0}
run: |

for file in $(find . -name "*.sh" ! -path '*/.git*/*' -exec grep -Iq . {} \; -print); do
if grep -qE "^#\!/.*bash" $file; then
shellcheck --severity=error $file || ret=$?
fi
done
if [[ -n "${{ steps.changed-files.outputs.all_changed_files }}" ]]; then
FILES="${{ steps.changed-files.outputs.all_changed_files }}"
for file in $FILES; do
if grep -qE "^#\!/.*bash" $file; then
shellcheck --severity=error $file || ret=$?
fi
done
else
FILES="$(find . -name "*.sh" ! -path '*/.git*/*' -exec grep -Iq . {} \; -print)"
for file in $FILES; do
if grep -qE "^#\!/.*bash" $file; then
shellcheck --severity=error $file || ret=$?
fi
done
fi
exit $ret
Loading