ci: add diff whitespace check#2572
Open
PascalThuet wants to merge 1 commit into
Open
Conversation
64f2d00 to
05a80fc
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a lightweight whitespace/conflict-marker validation to the existing GitHub Actions lint workflow by running git diff --check on the appropriate commit range for pull_request and push events.
Changes:
- Make the checkout explicitly shallow (
fetch-depth: 1). - Add a
git diff --checkstep that compares PR head vs PR base on PRs, and current vs “before” SHA on pushes tomain. - Handle the “new branch / root commit” push case via
git diff-tree --check --root.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/lint.yml | Adds a git diff --check gate to catch whitespace/conflict-marker issues in diffs during CI. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 3
Comment on lines
+26
to
+30
| run: | | ||
| if [ "$EVENT_NAME" = "pull_request" ]; then | ||
| git fetch --no-tags --depth=1 origin "$PR_BASE_SHA" | ||
| git diff --check "$PR_BASE_SHA" HEAD | ||
| elif [ "$PUSH_BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then |
Comment on lines
+27
to
+29
| if [ "$EVENT_NAME" = "pull_request" ]; then | ||
| git fetch --no-tags --depth=1 origin "$PR_BASE_SHA" | ||
| git diff --check "$PR_BASE_SHA" HEAD |
Comment on lines
+32
to
+34
| else | ||
| git fetch --no-tags --depth=1 origin "$PUSH_BEFORE_SHA" | ||
| git diff --check "$PUSH_BEFORE_SHA" HEAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a lightweight
git diff --checkvalidation step to the existing lint workflow.Changes
fetch-depth: 1.git diff --checkagainst the PR base/checked-out head range on pull requests.git diff --checkagainst the before/checked-out head range on pushes tomain.Notes
This mirrors the local whitespace check we have been using before opening PRs. It catches trailing whitespace, space-before-tab issues, and conflict markers in the changed diff without fetching full repository history.
Validation
Local:
uv run python -c "import yaml; yaml.safe_load(open('.github/workflows/lint.yml', encoding='utf-8'))"git diff --check origin/maingit diff-tree --check --no-commit-id --root -r HEADCI:
AI Disclosure
Used AI assistance to inspect the existing lint workflow, add the scoped CI check, and run local validation. The changes were reviewed before submission.