[SPARK-58045][INFRA] Verify the linked JIRA matches the PR in merge_spark_pr.py#57131
[SPARK-58045][INFRA] Verify the linked JIRA matches the PR in merge_spark_pr.py#57131gengliangwang wants to merge 4 commits into
merge_spark_pr.py#57131Conversation
…park_pr.py Add a verification step in merge_spark_pr.py that, after the committer enters the PR number, shows the PR title next to each linked JIRA's summary/status/type, warns in red when a ticket is already Resolved/Closed, and requires an explicit y/N confirmation before merging. This guards against merging a PR against the wrong ticket (e.g. mistaking a GitHub PR number for a SPARK JIRA id). Co-authored-by: Isaac
|
Thank you, @gengliangwang ! |
Add a title-similarity check to the JIRA verification block in merge_spark_pr.py. For each linked JIRA, compute a Jaccard word-overlap score between the PR title and the JIRA summary (component/version tags and stopwords stripped) and print it on a new "Match:" line, with a red warning when the score falls below a threshold (0.2) -- a strong signal the PR references the wrong ticket. The Epic/Umbrella case is already guarded by the existing hard-fail before this block, so no separate umbrella warning is added. Co-authored-by: Isaac
There was a problem hiding this comment.
Does this work for [FOLLOWUP] PRs, @gengliangwang ? Maybe, add a test case for the follow-up PR patterns? And, Revert PR pattern, too.
… title patterns Address review feedback: add title_similarity doctests covering the [FOLLOWUP] tag (stripped like any bracket tag, so a matching follow-up still scores 1.0) and the Revert "..." title pattern (kept verbatim, so the extra word lowers the score but a genuine match still scores well above the warning threshold). Co-authored-by: Isaac
|
Thanks @dongjoon-hyun! Good call on both — it works for both patterns:
I've added |
| 0.5 | ||
|
|
||
| A [FOLLOWUP] tag is stripped like any other bracket tag, so a follow-up whose | ||
| title still matches the ticket scores the same as the untagged title: |
There was a problem hiding this comment.
Is this true? Usually, the follow-up title is supposed to describe its code which is usually missed in the original PR. Like the following. The following is an example in branch-3.5.
$ git log --oneline | grep SPARK-56463
77117c7b32a [SPARK-56463][PYTHON][FOLLOWUP][3.5] Fix wrong kwargs
092f02df06e [SPARK-56463][PYTHON] Disallow unpickling UDT
There was a problem hiding this comment.
Typically, the follow-up PR title's score is not the same with the original PR title (and the JIRA issue title).
…OLLOWUP] PRs A follow-up PR title describes the fix it adds, not the original ticket, so it legitimately scores low against the JIRA summary even when it references the right ticket -- firing the low-similarity warning on the normal [FOLLOWUP] workflow and training committers to click through it. Suppress the warning when the title carries a [FOLLOWUP] tag: still show the Match score, but with an explanatory note instead of a warning. The Resolved/Closed warning and the warning for non-follow-up PRs are unchanged. Fix the misleading doctest that implied follow-up titles match the ticket. Co-authored-by: Isaac
|
Thank you for updating, @gengliangwang . |
merge_spark_pr.py
What changes were proposed in this pull request?
This PR adds a JIRA-vs-PR verification step to
dev/merge_spark_pr.py. After the committer enters the PR number (right after the existing Epic/Umbrella check, before the "Proceed with merging?" confirmation), the script now, for each SPARK JIRA id linked from the PR title, prints a verification block and requires an explicity/Nconfirmation. The block:Resolved/Closed(a fresh merge should target an open ticket);Match:score below a threshold), which is a strong signal the PR references the wrong ticket;y, asking them to fix the PR title.Implementation notes:
format_jira_verification(...)renders the block and is covered by inline doctests. Coloring the warnings is gated behind ause_colorflag (off in doctests so the expected output stays plain text, on at the real call site).title_similarity): bracket tags ([SQL], the leading[SPARK-xxxx], ...) are stripped, words are lowercased, a small stopword set is dropped, and the two token sets are compared. No new dependency. The warning fires belowSIMILARITY_WARN_THRESHOLD(0.2), tuned so an unrelated ticket (~0) warns while reworded-but-correct summaries stay above the line.linked_issues, so the verification step reuses those objects and performs no extra JIRA round-trips.red(...)helper was factored out ofprint_error(no behavior change) and reused for the warnings.No JIRA id is newly required by this change:
[MINOR]/[TRIVIAL]PRs still merge with no SPARK id (the loop is a no-op for them). The existingTitle.parserequirement is unchanged.[FOLLOWUP]PRs are handled (the id is extracted regardless of the tag), andRevert "..."PRs keep their title verbatim so the id is still extracted from it -- in both cases the warnings act as the intended nudge to double-check the ticket.Why are the changes needed?
merge_spark_pr.pyalready prints each linked JIRA's summary, but nothing forces the committer to confirm the ticket actually matches the PR. A PR can therefore be merged against the wrong ticket - for example when a GitHub PR number in the body (Closes #NNNNN) is mistaken for a SPARK JIRA id - which resolves an unrelated, possibly already-Resolved ticket on merge. This step surfaces both signals (title/summary mismatch and an already-resolved ticket) and requires a human confirmation before the merge proceeds.Does this PR introduce any user-facing change?
No. This only affects the committer-facing merge tooling.
How was this patch tested?
python3 -m doctest dev/merge_spark_pr.py- all doctests pass, including the newtitle_similaritycases (match, no-match, partial overlap,[FOLLOWUP], andReverttitle patterns) and the twoformat_jira_verificationcases (one exercising both warnings, one clean).use_color=Trueand confirmed both warnings are wrapped in the same red escape asprint_error.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)