Skip to content

ci: add line-endings check as a parallel verify job#1316

Merged
joaodinissf merged 1 commit into
dsldevkit:masterfrom
joaodinissf:chore/check-line-endings
May 6, 2026
Merged

ci: add line-endings check as a parallel verify job#1316
joaodinissf merged 1 commit into
dsldevkit:masterfrom
joaodinissf:chore/check-line-endings

Conversation

@joaodinissf
Copy link
Copy Markdown
Collaborator

@joaodinissf joaodinissf commented Apr 17, 2026

Summary

Adds a new line-endings job to verify.yml that runs in parallel with pmd, checkstyle, and maven-verify. It uses git ls-files --eol to check every text file in the index is stored as LF, exempting .bat/.cmd/.ps1 (the exceptions that .gitattributes keeps on CRLF for Windows compatibility).

A second layer of defence on top of the normalization filter introduced in #1314.

Why a second layer?

Git's clean filter (driven by .gitattributes: * text=auto eol=lf) normalizes text files at commit time. Two gaps slip through:

  1. Miscategorization. text=auto uses a null-byte heuristic to decide if a file is text. A text file with an early null byte (rare but possible — certain XML CDATA blocks, certain encoded configs) is treated as binary and not normalized. CRLF sneaks in unchanged.
  2. Filter bypass. A --literally commit or a custom hook path can skip the filter.

Neither is common, but both are silent. This check surfaces them before they matter.

Depends on

Depends on #1314 landing first so the repo is actually LF-clean when this check starts enforcing. Opened on top of lf-normalize branch content.

Verification that the check catches real violations

A test commit with a CRLF file pushed onto this branch (subsequently removed) showed the job correctly flagging the file:

Files with CRLF/mixed line endings stored in the index:
i/crlf  w/crlf  attr/text=auto eol=lf   test-crlf-should-fail-ci.txt
##[error]Process completed with exit code 1.

Job completed in ~5s. Git's own clean filter caught the first attempt (writing a CRLF file through normal git add); bypassing the filter required git hash-object --no-filters + git update-index --cacheinfo, simulating a real filter-bypass scenario.

🤖 Generated with Claude Code

@joaodinissf joaodinissf marked this pull request as draft April 17, 2026 23:41
@joaodinissf joaodinissf force-pushed the chore/check-line-endings branch 2 times, most recently from e662364 to a78cbdf Compare April 17, 2026 23:50
@joaodinissf joaodinissf changed the title ci: add line-ending check as first verify step ci: add line-endings check as a parallel verify job Apr 17, 2026
@joaodinissf joaodinissf marked this pull request as ready for review April 17, 2026 23:54
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) <noreply@anthropic.com>
@joaodinissf joaodinissf force-pushed the chore/check-line-endings branch from a78cbdf to 4b94672 Compare April 20, 2026 08:21
@joaodinissf joaodinissf enabled auto-merge (rebase) April 20, 2026 08:36
@joaodinissf joaodinissf requested a review from rubenporras April 20, 2026 11:48
@joaodinissf joaodinissf merged commit 1506caf into dsldevkit:master May 6, 2026
4 checks passed
@joaodinissf joaodinissf deleted the chore/check-line-endings branch May 19, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants