dongjoon-hyun commented on code in PR #60261: URL: https://github.com/apache/spark/pull/60261#discussion_r4540785566
########## dev/merge_spark_pr.py: ########## @@ -117,6 +117,8 @@ # See https://docs.github.com/en/actions/how-tos/manage-workflow-runs/skip-workflow-runs POST_MERGE_CI_INTERVALS = {"master": 10, "branch-4.x": 10} POST_MERGE_CI_SKIP_TRAILER = "skip-checks: true" +# A PR carrying this GitHub label always runs post-merge CI, regardless of the interval. Review Comment: **[4] Nit: the header comment at L116 no longer covers every commit.** It still says "Other commits get GitHub's documented workflow-skip trailer after a visible warning", but commits of a PR with this label no longer get the trailer. Could L116 add "unless the PR has the `do-not-skip-ci` label"? ########## dev/merge_spark_pr.py: ########## @@ -879,15 +889,23 @@ 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``. """ interval = POST_MERGE_CI_INTERVALS.get(target_ref) if interval is None: return False + if force_post_merge_ci: + print( + "Post-merge CI will run on %s: the PR has the %r label." Review Comment: **[1] The label does not guarantee post-merge CI when the PR body has a GitHub skip string.** `merge_pr` copies the PR body into the squash commit message and removes only `@` (L1021), and `_do_cherry_pick` keeps that message, removing only an inherited `skip-checks: true` trailer (L1118). GitHub also skips push workflows when the commit message contains `[skip ci]`, `[ci skip]`, `[no ci]`, `[skip actions]` or `[actions skip]` (see the [page](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/skip-workflow-runs) linked at L117). So for a labeled PR whose description quotes `[skip ci]`, e.g. an INFRA PR about CI skipping, the script prints this line, but no workflow runs on `master` or on any backport. L120 also says such a PR "always runs post-merge CI". Could `main()` warn when a labeled PR's body contains one of these strings, or could L120 and this message mention the exception? ########## dev/merge_spark_pr.py: ########## @@ -3203,6 +3245,9 @@ def main(): url = pr["url"] title = pr["title"] + force_post_merge_ci = POST_MERGE_CI_FORCE_LABEL in [ Review Comment: **[6] Nit: `any(...)` would avoid the throwaway list.** Could this be `any(label["name"] == POST_MERGE_CI_FORCE_LABEL for label in pr["labels"])`? The pulls API always returns `labels`, and the `.get` default seems to be there only for the `main_titles` fixture (L4007), which has no `labels` key. Adding `"labels": []` to that fixture would keep it closer to the real response. ########## dev/merge_spark_pr.py: ########## @@ -1034,7 +1068,7 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc, pr_author, co_author return merge_hash Review Comment: **[7] Minor: this predates the PR and is outside its diff, but a failed push ends in a traceback.** When `git.push` raises at L1059, the `except` calls `clean_up()`, which deletes every `PR_TOOL_*` branch, and only prints the error. L1064 then runs `git rev-parse` on the deleted `target_branch_name`, so a rejected push (e.g. a commit landed on `master` during the author or conflict prompts) ends with a raw `CalledProcessError` traceback. `_do_cherry_pick` calls `fail()` in the same place (L1131). Could `merge_pr` do the same, maybe in a follow-up? ########## dev/merge_spark_pr.py: ########## @@ -1034,7 +1068,7 @@ def merge_pr(pr_num, target_ref, title, body, pr_repo_desc, pr_author, co_author return merge_hash -def _do_cherry_pick(pr_num, merge_hash, pick_ref): +def _do_cherry_pick(pr_num, merge_hash, pick_ref, force_post_merge_ci=False): Review Comment: **[3] Minor: `force_post_merge_ci` defaults to `False` on every internal layer.** `merge_pr`, `cherry_pick`, `_do_cherry_pick` and `should_skip_post_merge_ci` all default it to `False`, and each call passes it on by hand (L996, L1083, L1266-1267, L1273, L1282, L3356, L3397, L3425). If a later change adds another `_do_cherry_pick` call, like the two in the Upstream-First branch at L1266-1267, and leaves the argument out, a labeled PR gets `skip-checks: true` on that branch with no error. Could the internal helpers take it as a required argument, or could `main()` set it once as a module-level global, as L3213 does for `git` and `original_head`? ########## dev/merge_spark_pr.py: ########## @@ -538,6 +540,10 @@ def red(text): return "\033[91m%s\033[0m" % text +def yellow(text): + return "\033[93m%s\033[0m" % text Review Comment: **[2] Minor: bright yellow is hard to read on a light terminal background.** I agree with the description that the skip warning need not look like an error. But `\033[93m` is the bright yellow, which is close to invisible on light themes (e.g. macOS Terminal's Basic profile in light mode), and this warning is the line that tells a committer about the trailer and the new label before the push prompt. Could it use the normal yellow (`\033[33m`), maybe with bold, or keep the red? ########## dev/merge_spark_pr.py: ########## @@ -546,6 +552,10 @@ def print_error(msg): print(red(msg)) +def print_warning(msg): + print(yellow(msg)) Review Comment: **[5] Nit: `print_warning` has one caller, so warnings now print in two colors.** The fix-version warnings at L1777 and L1924 still go through `print_error`, and the JIRA status and similarity warnings use `red()` (L1385 says they use "the same red as `print_error`"). Could those use `print_warning` too, or could the skip warning stay on `print_error`? If item 2 keeps the red, this goes away as well. -- 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]
