Skip to content

Commit

Permalink
Lint only changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Sep 24, 2024
1 parent 4614881 commit d13f51c
Showing 1 changed file with 25 additions and 5 deletions.
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

0 comments on commit d13f51c

Please sign in to comment.