Skip to content

fix(ci): normalize Windows CRLF line endings in PR governance script#1012

Open
Parideboy wants to merge 5 commits into
chopratejas:mainfrom
Parideboy:fix/governance-crlf-code-blocks
Open

fix(ci): normalize Windows CRLF line endings in PR governance script#1012
Parideboy wants to merge 5 commits into
chopratejas:mainfrom
Parideboy:fix/governance-crlf-code-blocks

Conversation

@Parideboy

@Parideboy Parideboy commented Jun 15, 2026

Copy link
Copy Markdown

Description

The CODE_BLOCK_RE regex in scripts/pr-governance.py expects LF after the opening fenced code block. PR bodies authored on Windows can arrive with CRLF line endings, which leaves a \r before the \n and prevents has_test_output() from detecting a valid Test Output block.

This normalizes CRLF to LF once when loading the pull request body, before section extraction and code-block matching. A regression test now verifies that a valid PR body with CRLF line endings still passes governance.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Tests only

Changes Made

  • Normalize Windows CRLF line endings in scripts/pr-governance.py before regex-based validation runs.
  • Added test_validate_pull_request_accepts_crlf_test_output_code_block to prevent regressions.

Testing

  • Unit tests pass (pytest)
  • Linting passes (ruff check)
  • Formatting passes (ruff format --check)
  • New tests added for new functionality

Test Output

python -m pytest scripts/tests/test_pr_governance.py scripts/tests/test_pr_health_labels.py scripts/tests/test_pr_health_workflow.py -q
8 passed in 0.06s

ruff check scripts/pr-governance.py scripts/tests/test_pr_governance.py scripts/tests/test_pr_health_labels.py scripts/tests/test_pr_health_workflow.py
All checks passed!

ruff format --check scripts/pr-governance.py scripts/tests/test_pr_governance.py scripts/tests/test_pr_health_labels.py scripts/tests/test_pr_health_workflow.py
4 files already formatted

Real Behavior Proof

  • Environment: local Windows 11 checkout, Python 3.13.13.
  • Exact command / steps: Converted the known-valid governance test body to CRLF line endings and passed it through validate_pull_request in the new regression test.
  • Observed result: The report is valid with no problems, proving the fenced Test Output block is recognized after normalization.
  • Not tested: GitHub-hosted Windows PR authoring path end to end; the unit test covers the exact CRLF body shape consumed by the validator.

Review Readiness

  • I have performed a self-review
  • This PR is ready for human review

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

PR governance

This PR follows the template and is marked ready for human review.

@github-actions github-actions Bot added the status: needs author action Pull request body or readiness checklist still needs author updates label Jun 15, 2026
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chopratejas

Copy link
Copy Markdown
Owner

Do you know why we have so many failures? Related to your fix? I dont think so - but want to check

@github-actions github-actions Bot added the status: ci failing Required or reported CI checks are failing label Jun 15, 2026
@Parideboy

Copy link
Copy Markdown
Author

Do you know why we have so many failures? Related to your fix? I dont think so - but want to check

No idea, I will take a closer look after work. But it's mostly related to torch installation issues:

Three test jobs are failing because of duplicate PyTorch CPU index URLs. The global PIP_EXTRA_INDEX_URL is already set, but individual jobs are passing --index-url again, creating duplicates.

Fixes needed in .github/workflows/ci.yml:

Line 185 (test job): Remove --index-url https://download.pytorch.org/whl/cpu
Line 247 (test-extras job): Remove --index-url https://download.pytorch.org/whl/cpu
Line 289 (test-agno job): Remove --index-url https://download.pytorch.org/whl/cpu
Line 315 (test-dashboard-ui job): Remove --index-url https://download.pytorch.org/whl/cpu

If index-url must be used, it can be replaced with --extra-index-url. Is there a reason why it was added in the first place? PyPI should handle this on it's own

CODE_BLOCK_RE hardcodes \n (LF) after the opening fence, but PR bodies
authored on Windows use \r\n (CRLF). When the regex hits \r before \n at
that position the match fails silently: has_test_output() returns False
and the bot reports 'Paste real command output' even when the code block
is present and correct.

Fix: normalize \r\n to \n at the top of validate_pull_request before any
regex runs. Covers all pattern matches, not just the code-block regex,
and future-proofs against similar \r\n issues.
@Parideboy Parideboy force-pushed the fix/governance-crlf-code-blocks branch from e097a85 to 8a92754 Compare June 16, 2026 05:40
@JerrettDavis JerrettDavis force-pushed the fix/governance-crlf-code-blocks branch from 8a92754 to 99c772d Compare June 16, 2026 18:45
@github-actions github-actions Bot added status: ready for review Pull request body is complete and the author marked it ready for human review and removed status: ci failing Required or reported CI checks are failing status: needs author action Pull request body or readiness checklist still needs author updates labels Jun 16, 2026

@JerrettDavis JerrettDavis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the CRLF normalization change and the added regression coverage. Focused governance tests passed locally and current checks are green.

Parideboy and others added 2 commits June 16, 2026 14:11
CODE_BLOCK_RE hardcodes \n (LF) after the opening fence, but PR bodies
authored on Windows use \r\n (CRLF). When the regex hits \r before \n at
that position the match fails silently: has_test_output() returns False
and the bot reports 'Paste real command output' even when the code block
is present and correct.

Fix: normalize \r\n to \n at the top of validate_pull_request before any
regex runs. Covers all pattern matches, not just the code-block regex,
and future-proofs against similar \r\n issues.
@JerrettDavis JerrettDavis force-pushed the fix/governance-crlf-code-blocks branch from 99c772d to 76809a1 Compare June 16, 2026 19:12
@github-actions github-actions Bot added status: ci failing Required or reported CI checks are failing and removed status: ready for review Pull request body is complete and the author marked it ready for human review labels Jun 17, 2026

@JerrettDavis JerrettDavis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR is not merge-ready because CI is currently red: test (3)=FAILURE, test (2)=FAILURE. Please fix or rerun the failing checks after updating from current main.

@github-actions github-actions Bot added status: ready for review Pull request body is complete and the author marked it ready for human review and removed status: ci failing Required or reported CI checks are failing labels Jun 19, 2026
@Parideboy Parideboy requested a review from JerrettDavis June 19, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready for review Pull request body is complete and the author marked it ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants