Skip to content

Commit c8bf685

Browse files
committed
Adding tests and log statements
1 parent ca837ba commit c8bf685

3 files changed

Lines changed: 369 additions & 3 deletions

File tree

release/github.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,37 @@
1717

1818
"""
1919
Auxiliary functions to interact with the GitHub REST API.
20+
21+
Set the GITHUB_REPO environment variable to override the target repository
22+
(e.g. "myuser/kafka" to test against a personal fork).
23+
24+
Set GITHUB_DRY_RUN=true to print API calls without executing them.
2025
"""
2126

2227
import json
28+
import os
2329
import urllib.request
2430

2531
from runtime import fail
2632

2733
GITHUB_API_URL = "https://api.github.com"
28-
GITHUB_REPO = "apache/kafka"
34+
GITHUB_REPO = os.environ.get("GITHUB_REPO", "apache/kafka")
35+
DRY_RUN = os.environ.get("GITHUB_DRY_RUN", "").lower() in ("true", "1", "yes")
2936

3037

3138
def _api_request(token, method, path, body=None):
3239
"""
3340
Make an authenticated request to the GitHub REST API.
41+
In dry-run mode, prints the request details without executing.
3442
"""
3543
url = f"{GITHUB_API_URL}{path}"
44+
45+
if DRY_RUN:
46+
print(f"[DRY RUN] {method} {url}")
47+
if body:
48+
print(f"[DRY RUN] Body: {json.dumps(body, indent=2)}")
49+
return None
50+
3651
data = json.dumps(body).encode("utf-8") if body else None
3752
req = urllib.request.Request(url, data=data, method=method)
3853
req.add_header("Accept", "application/vnd.github.v3+json")
@@ -56,7 +71,7 @@ def trigger_workflow(token, workflow_file, ref, inputs):
5671
"""
5772
path = f"/repos/{GITHUB_REPO}/actions/workflows/{workflow_file}/dispatches"
5873
body = {"ref": ref, "inputs": inputs}
59-
print(f"Triggering workflow {workflow_file} with inputs: {json.dumps(inputs)}")
74+
print(f"Triggering workflow {workflow_file} on {GITHUB_REPO} with inputs: {json.dumps(inputs)}")
6075
_api_request(token, "POST", path, body)
6176
print(f"Successfully triggered {workflow_file}")
6277

@@ -65,6 +80,10 @@ def trigger_docker_build_test(token, ref, image_type, kafka_url):
6580
"""
6681
Trigger the Docker Build Test workflow for the given image type.
6782
"""
83+
print(f"\n--- Docker Build Test ({image_type}) ---")
84+
print(f" Image type : {image_type}")
85+
print(f" Branch/ref : {ref}")
86+
print(f" Kafka URL : {kafka_url}")
6887
trigger_workflow(token, "docker_build_and_test.yml", ref, {
6988
"image_type": image_type,
7089
"kafka_url": kafka_url,
@@ -75,6 +94,11 @@ def trigger_docker_rc_release(token, ref, image_type, rc_docker_image, kafka_url
7594
"""
7695
Trigger the Docker RC Release workflow for the given image type.
7796
"""
97+
print(f"\n--- Docker RC Release ({image_type}) ---")
98+
print(f" Image type : {image_type}")
99+
print(f" Docker image : {rc_docker_image}")
100+
print(f" Branch/ref : {ref}")
101+
print(f" Kafka URL : {kafka_url}")
78102
trigger_workflow(token, "docker_rc_release.yml", ref, {
79103
"image_type": image_type,
80104
"rc_docker_image": rc_docker_image,

release/release.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,17 +374,28 @@ def delete_gitrefs():
374374
git.push_ref(starting_branch)
375375

376376
# Trigger Docker image build and test workflows via GitHub Actions
377+
print("\n=== Docker Image Workflows ===")
378+
if github.DRY_RUN:
379+
print("NOTE: GITHUB_DRY_RUN is enabled. No actual API calls will be made.")
380+
if github.GITHUB_REPO != "apache/kafka":
381+
print(f"NOTE: Using custom repository: {github.GITHUB_REPO}")
377382
if confirm("Trigger Docker image build workflows via GitHub Actions?"):
378383
github_token = preferences.get('github_token', lambda: prompt("Enter your GitHub personal access token (with 'actions' scope): "))
379384
kafka_url = f"https://dist.apache.org/repos/dist/dev/kafka/{rc_tag}/kafka_2.13-{release_version}.tgz"
385+
print(f"\nStep 1/2: Triggering Docker Build Test workflows for JVM and native images...")
380386
for image_type in ["jvm", "native"]:
381387
github.trigger_docker_build_test(github_token, dev_branch, image_type, kafka_url)
388+
print("\nDocker Build Test workflows triggered successfully for both JVM and native images.")
382389
if confirm("Also trigger Docker RC release workflows to push RC images to DockerHub?"):
390+
print(f"\nStep 2/2: Triggering Docker RC Release workflows for JVM and native images...")
383391
for image_type in ["jvm", "native"]:
384392
docker_image_name = "apache/kafka-native" if image_type == "native" else "apache/kafka"
385393
rc_docker_image = f"{docker_image_name}:{rc_tag}"
386394
github.trigger_docker_rc_release(github_token, dev_branch, image_type, rc_docker_image, kafka_url)
387-
print(f"\nDocker workflow runs can be monitored at: https://github.com/apache/kafka/actions")
395+
print("\nDocker RC Release workflows triggered successfully for both JVM and native images.")
396+
print(f"\nAll Docker workflow runs can be monitored at: https://github.com/{github.GITHUB_REPO}/actions")
397+
else:
398+
print("Skipping Docker image workflows.")
388399

389400
# Move back to starting branch and clean out the temporary release branch (e.g. 1.0.0) we used to generate everything
390401
git.reset_hard_head()

0 commit comments

Comments
 (0)