[v3-1-test] Add CI workflow to validate newsfragment PR numbers (#62975)#62986
Draft
github-actions[bot] wants to merge 1 commit intov3-1-testfrom
Draft
[v3-1-test] Add CI workflow to validate newsfragment PR numbers (#62975)#62986github-actions[bot] wants to merge 1 commit intov3-1-testfrom
github-actions[bot] wants to merge 1 commit intov3-1-testfrom
Conversation
* Add CI workflow to validate newsfragment PR numbers
Newsfragment files follow the naming convention `{pr_number}.{type}.rst`,
but nothing currently validates that the PR number in the filename matches
the actual PR number. This has led to cases where a contributor copies a
newsfragment from another PR or makes a typo, and the mismatch goes
unnoticed until a reviewer catches it manually.
The existing `scripts/ci/prek/newsfragments.py` validation script runs as
a local pre-commit hook where the PR number is not yet known, so it cannot
perform this check. Rather than extending that script with optional CLI
args and a separate CI invocation, this adds a standalone lightweight
workflow that uses `gh pr diff --name-only` to get the list of changed
files, greps for newsfragment `.rst` files, and checks that none have a
mismatched PR number — all in a single piped command, no checkout needed.
Notes for reviewers:
- `gh pr diff --name-only` includes deleted files. In practice, newsfragment
deletions only happen during towncrier releases on main, not in contributor
PRs, so this is not a concern for the `pull_request` trigger.
- `GH_TOKEN: ${{ github.token }}` follows the same pattern as
`milestone-tag-assistant.yml` and `backport-cli.yml` which also call `gh`
CLI directly.
- The `pull-requests: read` permission is required for `gh pr diff` to work
on fork PRs.
* fixup! Add CI workflow to validate newsfragment PR numbers
fixup! Add CI workflow to validate newsfragment PR numbers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
(cherry picked from commit dd755d8)
Co-authored-by: Xiaodong Deng <xd_deng@hotmail.com>
Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 task
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.
Newsfragment files follow the naming convention
{pr_number}.{type}.rst,but nothing currently validates that the PR number in the filename matches
the actual PR number. This has led to cases where a contributor copies a
newsfragment from another PR or makes a typo, and the mismatch goes
unnoticed until a reviewer catches it manually.
The existing
scripts/ci/prek/newsfragments.pyvalidation script runs asa local pre-commit hook where the PR number is not yet known, so it cannot
perform this check. Rather than extending that script with optional CLI
args and a separate CI invocation, this adds a standalone lightweight
workflow that uses
gh pr diff --name-onlyto get the list of changedfiles, greps for newsfragment
.rstfiles, and checks that none have amismatched PR number — all in a single piped command, no checkout needed.
Notes for reviewers:
gh pr diff --name-onlyincludes deleted files. In practice, newsfragmentdeletions only happen during towncrier releases on main, not in contributor
PRs, so this is not a concern for the
pull_requesttrigger.GH_TOKEN: ${{ github.token }}follows the same pattern asmilestone-tag-assistant.ymlandbackport-cli.ymlwhich also callghCLI directly.
pull-requests: readpermission is required forgh pr diffto workon fork PRs.
fixup! Add CI workflow to validate newsfragment PR numbers
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
(cherry picked from commit dd755d8)
Co-authored-by: Xiaodong Deng xd_deng@hotmail.com
Co-authored-by: Jarek Potiuk jarek@potiuk.com
Co-authored-by: Claude Opus 4.6 noreply@anthropic.com