This is an automated email from the ASF dual-hosted git repository.
szehon-ho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark-docker.git
The following commit(s) were added to refs/heads/master by this push:
new 51ab904 Post merge summary comments from the Docker merge script
51ab904 is described below
commit 51ab904ef98dbac2365b90edeea2315e42348941
Author: Szehon Ho <[email protected]>
AuthorDate: Wed Oct 28 14:31:10 2026 -0700
Post merge summary comments from the Docker merge script
### What changes were proposed in this pull request?
After a successful push, `dev/merge_spark_docker_pr.py` posts a **Merge
Summary** comment on the pull request with the target branch and resulting
commit link. This ports the comment behavior from Spark's
`dev/merge_spark_pr.py`, using the existing `GITHUB_OAUTH_KEY` for
authentication.
The script skips the comment when no token is configured and reports HTTP
or connection errors while allowing the JIRA update to continue.
### Why are the changes needed?
Record where the change landed directly on the pull request, so
contributors can find the resulting commit after a squash merge.
### Does this PR introduce _any_ user-facing change?
Committers who configure `GITHUB_OAUTH_KEY` now get an automatic merge
summary comment on the pull request.
### How was this patch tested?
- `PYTHONDONTWRITEBYTECODE=1 python3 -m doctest -v
dev/merge_spark_docker_pr.py`: all 9 doctests passed.
- Ran 6 focused checks with mocked Git, GitHub, and JIRA calls: comment
formatting and authentication for master and a release branch; skipping without
a token; posting after a successful push and before JIRA; avoiding comments
after failed pushes; and continuing JIRA updates after missing tokens, HTTP
errors, or connection errors. These checks were run locally without adding a
new test harness to the repository.
- `git diff --check` passed.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-6)
Closes #142 from szehon-ho/codex/merge-pr-comment.
Authored-by: Szehon Ho <[email protected]>
Signed-off-by: Szehon Ho <[email protected]>
---
dev/merge_spark_docker_pr.py | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/dev/merge_spark_docker_pr.py b/dev/merge_spark_docker_pr.py
index d8788df..b7d2a26 100755
--- a/dev/merge_spark_docker_pr.py
+++ b/dev/merge_spark_docker_pr.py
@@ -33,7 +33,7 @@ import sys
import traceback
from urllib.request import urlopen
from urllib.request import Request
-from urllib.error import HTTPError
+from urllib.error import HTTPError, URLError
try:
import jira.client
@@ -56,10 +56,12 @@ JIRA_PASSWORD = os.environ.get("JIRA_PASSWORD", "")
# will be unauthenticated. You should only need to configure this if you find
yourself regularly
# exceeding your IP's unauthenticated request rate limit. You can create an
OAuth key at
# https://github.com/settings/tokens. This script only requires the
"public_repo" scope.
+# A token is required to post the merge summary comment on the pull request.
GITHUB_OAUTH_KEY = os.environ.get("GITHUB_OAUTH_KEY")
GITHUB_BASE = "https://github.com/apache/spark-docker/pull"
+GITHUB_COMMIT_BASE = "https://github.com/apache/spark-docker/commit"
GITHUB_API_BASE = "https://api.github.com/repos/apache/spark-docker"
JIRA_BASE = "https://issues.apache.org/jira/browse"
JIRA_API_BASE = "https://issues.apache.org/jira"
@@ -85,6 +87,30 @@ def get_json(url):
sys.exit(-1)
+def post_merge_comment(pr_num, target_ref, merge_hash):
+ if not GITHUB_OAUTH_KEY:
+ print("GITHUB_OAUTH_KEY is not set; skipping the merge comment.")
+ return
+
+ body = (
+ "**Merge Summary:**\n- merged into %s %s/%s\n\n"
+ "*Posted by `merge_spark_docker_pr.py`*"
+ ) % (target_ref, GITHUB_COMMIT_BASE, merge_hash)
+ print("\nPosting merge comment on PR #%s:\n%s" % (pr_num, body))
+
+ url = "%s/issues/%s/comments" % (GITHUB_API_BASE, pr_num)
+ data = json.dumps({"body": body}).encode("utf-8")
+ request = Request(url, data=data, method="POST")
+ request.add_header("Content-Type", "application/json")
+ request.add_header("Accept", "application/vnd.github+json")
+ request.add_header("Authorization", "token %s" % GITHUB_OAUTH_KEY)
+ try:
+ with urlopen(request) as response:
+ return json.load(response)
+ except URLError as e:
+ print("Failed to comment on PR #%s: %s" % (pr_num, e))
+
+
def fail(msg):
print(msg)
clean_up()
@@ -539,7 +565,8 @@ def main():
merged_refs = [target_ref]
- merge_pr(pr_num, target_ref, title, body, pr_repo_desc)
+ merge_hash = merge_pr(pr_num, target_ref, title, body, pr_repo_desc)
+ post_merge_comment(pr_num, target_ref, merge_hash)
if JIRA_IMPORTED:
if JIRA_USERNAME and JIRA_PASSWORD:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]