spark-test commented on code in PR #60261:
URL: https://github.com/apache/spark/pull/60261#discussion_r4519768893


##########
dev/merge_spark_pr.py:
##########
@@ -879,11 +889,19 @@ def clean_up():
             git.run("git branch -D %s" % branch)
 
 
-def should_skip_post_merge_ci(target_ref):
+def should_skip_post_merge_ci(target_ref, force_post_merge_ci=False):
     """Return whether the next commit on ``target_ref`` should skip post-merge 
CI.
 
     The branch history count matches the check formerly performed in 
``build_main.yml``.
+    ``force_post_merge_ci`` is set when the PR carries 
``POST_MERGE_CI_FORCE_LABEL``.
     """
+    if force_post_merge_ci:

Review Comment:
   **Nit (P3):** No doctest reaches this early return or the label path that 
feeds it. No example calls `should_skip_post_merge_ci`, `merge_pr`, 
`cherry_pick`, or `_do_cherry_pick`. `main_titles`, the only doctest that runs 
`main()`, builds its PR fixture without a `labels` key and never checks the 
`force_post_merge_ci` keyword it passes to its `merge_pr` and `cherry_pick` 
mocks. So inverting the label match in `main()`, deleting this branch or making 
it return `True`, or dropping the flag at any of the forwarding calls would 
leave every doctest passing, and labeled PRs would quietly get `skip-checks: 
true` again. These doctests run only through the `doctest.testmod()` call 
before each merge; CI doesn't run them.
   
   Could you add doctests for this path? This branch returns before any git 
call, so a direct example is cheap, and the off-interval cases you ran with a 
fake git would fit there. A `main_titles`-style case with a labeled fixture can 
check the keyword that `merge_pr` and `cherry_pick` receive, and small mocked 
examples can cover the forwarding inside `cherry_pick`, `merge_pr`, and 
`_do_cherry_pick`.
   
   **Verification:**
   - **Behavior:** For a PR carrying the do-not-skip-ci label, the trailer 
decision is False on a sampled branch whose next commit count is off-interval 
and the flag reaches the squash merge and every cherry-pick; for a PR without 
it, the flag is False and the interval decides.
   - **Regression:** Each change the review found undetected now fails the 
doctest suite: an inverted label match, a removed or inverted forced early 
return, and a missing flag at any call between main() and the trailer decision.
   - **Compatibility:** The existing doctest expectations for main()'s 
committed titles, JIRA checks and updates, component prompts, and exit codes 
still hold.



##########
dev/merge_spark_pr.py:
##########
@@ -896,10 +914,17 @@ def should_skip_post_merge_ci(target_ref):
         )
         return False
 
-    print_error(
+    print_warning(
         "WARNING: Post-merge CI will be skipped on %s because commit count %s 
is not "
-        "divisible by %s. GitHub's %r trailer will be added."
-        % (target_ref, commit_count, interval, POST_MERGE_CI_SKIP_TRAILER)
+        "divisible by %s. GitHub's %r trailer will be added. To force 
post-merge CI to "
+        "run, add the %r label to the PR and rerun this script."

Review Comment:
   **Nit (P3):** This hint prints in `merge_pr` before `git merge --squash` and 
before the "Enter primary author" prompt, which takes any text and can't be 
declined. A committer who stops there to follow it, with Ctrl-C at that prompt 
or by answering N at a conflicted squash's fix-up prompt, ends up in 
`clean_up()`. That function only checks out the starting branch and deletes the 
`PR_TOOL_*` branches; it never resets the index. Replaying those git steps with 
git 2.47.3:
   
   - If the starting branch has a different copy of a file the PR touches, the 
checkout fails and HEAD stays on `PR_TOOL_MERGE_PR_<N>_MASTER` with the squash 
staged. The advised rerun then fails at `git fetch apache 
master:PR_TOOL_MERGE_PR_<N>_MASTER` ("refusing to fetch into branch ... checked 
out").
   - If the copies match, the staged squash moves onto the committer's own 
branch. The rerun's `git merge --squash` then fails with "Your local changes 
... would be overwritten by merge", unless the PR branch is based on the target 
branch's current tip.
   - After a conflicted squash, the checkout fails and the conflict stays on 
the `PR_TOOL` branch.
   
   Nothing gets pushed, but each of these failures needs manual repair of the 
checkout before the rerun works. The only clean exit is answering N at the 
"Push to apache?" prompt after the squash is committed, so the hint could point 
there. The cherry-pick path is unaffected: every prompt after the hint there 
can be declined safely.
   
   ```suggestion
           "run, answer N at the push prompt, add the %r label to the PR, and 
rerun this script."
   ```
   
   **Verification:**
   - **Behavior:** On a sampled-out squash merge of an unlabeled PR, the 
warning tells the committer to answer N at the push prompt; answering N there 
leaves the starting branch checked out with a clean index and no PR_TOOL_* 
branches, and rerunning after adding the label merges without the skip trailer.
   - **Regression:** Whether the committer's starting branch has the same or a 
different copy of a file the PR touches than the target branch, and whether or 
not the PR's head descends from the target branch's tip, following the hint as 
printed leaves the starting branch checked out with nothing staged and no 
PR_TOOL_* branches, and the rerun's fetch and squash merge of the target branch 
succeed.
   - **Compatibility:** Which commits get the skip trailer is unchanged for 
labeled and unlabeled PRs, for on-interval and off-interval commit counts, and 
for branches with no configured interval, on both the squash merge and every 
cherry-pick.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to