From 0b4f67938f7ed54a6133a9c24534ef54d18e1b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vill=C5=91=20Sz=C5=B1cs?= Date: Thu, 30 Nov 2023 16:16:11 +0100 Subject: [PATCH] Fix check status handling in merge_pr function Change-Id: I99844bfac98c90e9bb525cb8d3eae5a465a56629 --- zk-merge-pr.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) mode change 100644 => 100755 zk-merge-pr.py diff --git a/zk-merge-pr.py b/zk-merge-pr.py old mode 100644 new mode 100755 index b63eb9fb0e3..8365620071e --- a/zk-merge-pr.py +++ b/zk-merge-pr.py @@ -157,13 +157,17 @@ def merge_pr(pr_num, title, pr_repo_desc): # Get the latest commit SHA. latest_commit_sha = json_pr["head"]["sha"] - json_status = get_json(f"https://api.github.com/repos/{PUSH_REMOTE_NAME}/{PROJECT_NAME}/statuses/{latest_commit_sha}") + json_status = get_json(f"https://api.github.com/repos/{PUSH_REMOTE_NAME}/{PROJECT_NAME}/commits/{latest_commit_sha}/check-runs") # Check if all checks have passed on GitHub. - all_checks_passed = all(status["state"] == "success" for status in json_status) + all_checks_passed = all(status["conclusion"] == "success" for status in json_status["check_runs"]) if all_checks_passed: print("All checks have passed on the github.") else: - continue_maybe("Warning: Not all checks have passed on the github. Would you like to continue the merge? (y/n): ") + any_in_progress = any(run["status"] == "in_progress" for run in json_status["check_runs"]) + if any_in_progress: + continue_maybe("Warning: There are pending checks. Would you like to continue the merge? (y/n): ") + else: + continue_maybe("Warning: Not all checks have passed on GitHub. Would you like to continue the merge? (y/n): ") headers = { "Authorization": f"token {GITHUB_OAUTH_KEY}",