From 4b946725d9de28634041b85992cb98f88c17e432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Dinis=20Ferreira?= Date: Sat, 18 Apr 2026 01:40:13 +0200 Subject: [PATCH] ci: add line-endings check as a parallel verify job Add a new `line-endings` job to `verify.yml` that runs alongside `pmd`, `checkstyle`, and `maven-verify`. It uses `git ls-files --eol` to check every text file in the index is stored as LF, exempting the `.bat`/`.cmd`/`.ps1` extensions that `.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. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/verify.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 1be908ba8..5156cfc3d 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -28,6 +28,24 @@ jobs: run: echo "WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV - name: Checkstyle Check run: mvn checkstyle:checkstyle checkstyle:check -f ./ddk-parent/pom.xml --batch-mode --fail-at-end + line-endings: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + - name: Check LF line endings in index + # .gitattributes declares `* text=auto eol=lf` with .bat/.cmd/.ps1 + # exempted. Git's clean filter normalizes on commit, but verify it + # explicitly in case a file is miscategorized as binary or a filter + # is bypassed. + run: | + violations=$(git ls-files --eol \ + | grep -E "^i/(crlf|mixed)" \ + | grep -vE "\.(bat|cmd|ps1)$" || true) + if [ -n "$violations" ]; then + echo "Files with CRLF/mixed line endings stored in the index:" + echo "$violations" + exit 1 + fi maven-verify: runs-on: ubuntu-24.04 steps: