Skip to content

ci: add diff whitespace check#2572

Open
PascalThuet wants to merge 1 commit into
github:mainfrom
PascalThuet:codex/ci-diff-whitespace-check
Open

ci: add diff whitespace check#2572
PascalThuet wants to merge 1 commit into
github:mainfrom
PascalThuet:codex/ci-diff-whitespace-check

Conversation

@PascalThuet
Copy link
Copy Markdown
Contributor

@PascalThuet PascalThuet commented May 15, 2026

Summary

Adds a lightweight git diff --check validation step to the existing lint workflow.

Changes

  • Keep checkout shallow with fetch-depth: 1.
  • Fetch only the comparison base needed for the current event.
  • Run git diff --check against the PR base/checked-out head range on pull requests.
  • Run git diff --check against the before/checked-out head range on pushes to main.

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/main
  • git diff-tree --check --no-commit-id --root -r HEAD

CI:

  • This PR exercises the updated lint workflow through GitHub Actions.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

Used AI assistance to inspect the existing lint workflow, add the scoped CI check, and run local validation. The changes were reviewed before submission.

@PascalThuet PascalThuet force-pushed the codex/ci-diff-whitespace-check branch from 64f2d00 to 05a80fc Compare May 15, 2026 06:08
@PascalThuet PascalThuet marked this pull request as ready for review May 15, 2026 06:10
@PascalThuet PascalThuet requested a review from mnriem as a code owner May 15, 2026 06:10
@mnriem mnriem requested a review from Copilot May 15, 2026 18:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --check step that compares PR head vs PR base on PRs, and current vs “before” SHA on pushes to main.
  • 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
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.

3 participants