Skip to content

Commit e662364

Browse files
joaodinissfclaude
andcommitted
ci: add line-ending check as first verify step
Add a new `line-endings` job to `verify.yml` that runs before any other verify job via `needs:`. It uses `git ls-files --eol` to check that every text file in the index is stored as LF, exempting the `.bat`/`.cmd`/`.ps1` extensions that the `.gitattributes` keeps on CRLF for Windows compatibility. The check is redundant with Git's own clean filter (which normalizes on commit per `.gitattributes: * text=auto eol=lf`) but catches two gaps: * A file that Git's `text=auto` heuristic misclassifies as binary (e.g., an early null byte) silently keeps whatever line endings it was committed with. * A filter-bypass via `--literally` or a custom hook path. Making the other three verify jobs (`pmd`, `checkstyle`, `maven-verify`) depend on this one means a line-ending violation fails the pipeline within seconds instead of a Maven build later. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7069be3 commit e662364

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/verify.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
pull_request:
66
jobs:
77
pmd:
8+
needs: line-endings
89
runs-on: ubuntu-24.04
910
steps:
1011
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
@@ -17,6 +18,7 @@ jobs:
1718
- name: PMD Check
1819
run: mvn pmd:pmd pmd:cpd pmd:check pmd:cpd-check -f ./ddk-parent/pom.xml --batch-mode --fail-at-end
1920
checkstyle:
21+
needs: line-endings
2022
runs-on: ubuntu-24.04
2123
steps:
2224
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
@@ -28,7 +30,26 @@ jobs:
2830
run: echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV
2931
- name: Checkstyle Check
3032
run: mvn checkstyle:checkstyle checkstyle:check -f ./ddk-parent/pom.xml --batch-mode --fail-at-end
33+
line-endings:
34+
runs-on: ubuntu-24.04
35+
steps:
36+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
37+
- name: Check LF line endings in index
38+
# .gitattributes declares `* text=auto eol=lf` with .bat/.cmd/.ps1
39+
# exempted. Git's clean filter normalizes on commit, but verify it
40+
# explicitly in case a file is miscategorized as binary or a filter
41+
# is bypassed.
42+
run: |
43+
violations=$(git ls-files --eol \
44+
| grep -E "^i/(crlf|mixed)" \
45+
| grep -vE "\.(bat|cmd|ps1)$" || true)
46+
if [ -n "$violations" ]; then
47+
echo "Files with CRLF/mixed line endings stored in the index:"
48+
echo "$violations"
49+
exit 1
50+
fi
3151
maven-verify:
52+
needs: line-endings
3253
runs-on: ubuntu-24.04
3354
steps:
3455
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

0 commit comments

Comments
 (0)