Skip to content

Commit dd54795

Browse files
authored
[CI] Fix nolint-check that are reporting always OK (#678)
1 parent cc1d668 commit dd54795

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.github/workflows/static-analysis-pr.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,31 @@ jobs:
124124
runs-on: ubuntu-24.04
125125
steps:
126126
- uses: actions/checkout@v5
127+
with:
128+
fetch-depth: 0
127129
- name: Search for linter suppression markers
130+
env:
131+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
132+
HEAD_SHA: ${{ github.sha }}
128133
run: |
129-
export BASE_REF=${{ github.event.pull_request.base.ref }}
130-
export CHANGED_FILES="$(git diff --name-only origin/$BASE_REF HEAD | grep '^tasks/')"
134+
set -euo pipefail
135+
136+
CHANGED_FILES="$(git diff --name-only "$BASE_SHA"..."$HEAD_SHA" -- 'tasks/')"
137+
131138
if [ -z "$CHANGED_FILES" ]; then
132139
echo "No changed files in tasks directory."
133140
exit 0
134141
fi
142+
135143
for file in $CHANGED_FILES; do
136-
if grep -n "NOLINT" "$file"; then
144+
if grep -q "NOLINT" "$file"; then
137145
echo "::error::Found 'NOLINT' in $file."
138146
exit 1
139147
fi
140-
if grep -En 'IWYU[[:space:]]+pragma' "$file"; then
148+
if grep -Eq 'IWYU[[:space:]]+pragma' "$file"; then
141149
echo "::error::Found 'IWYU pragma' in $file."
142150
exit 1
143151
fi
144152
done
153+
145154
echo "No linter suppression markers found in changed files."

0 commit comments

Comments
 (0)