Update check_actions_status.py

This commit is contained in:
Nicholas Tindle
2024-08-20 14:38:05 -05:00
parent a6a1717836
commit 828aabf532

View File

@@ -38,34 +38,34 @@ def make_api_request(url: str, headers: Dict[str, str]) -> Dict:
sys.exit(1)
def process_check_runs(
check_runs: List[Dict], current_run_id: str
) -> Tuple[bool, bool]:
def process_check_runs(check_runs: List[Dict]) -> Tuple[bool, bool]:
"""Process check runs and return their status."""
runs_in_progress = False
all_others_passed = True
for run in check_runs:
if str(run["id"]) != current_run_id:
status = run["status"]
conclusion = run["conclusion"]
# Ignore the "Check PR Status" run
if run["name"] == "Check PR Status":
continue
if status == "completed":
if conclusion not in ["success", "skipped", "neutral"]:
all_others_passed = False
print(
f"Check run {run['name']} (ID: {run['id']}) has conclusion: {conclusion}"
)
else:
runs_in_progress = True
print(f"Check run {run['name']} (ID: {run['id']}) is still {status}.")
all_others_passed = False
status = run["status"]
conclusion = run["conclusion"]
print(
f"Check run {run['name']} (ID: {run['id']}) status: {status}, conclusion: {conclusion}"
)
if status != "completed":
runs_in_progress = True
all_others_passed = False
elif conclusion not in ["success", "skipped", "neutral"]:
all_others_passed = False
return runs_in_progress, all_others_passed
def main():
api_url, repo, sha, github_token, current_run_id = get_environment_variables()
api_url, repo, sha, github_token, _ = get_environment_variables()
endpoint = f"{api_url}/repos/{repo}/commits/{sha}/check-runs"
headers = {
@@ -73,22 +73,16 @@ def main():
"Accept": "application/vnd.github.v3+json",
}
print(f"Current run ID: {current_run_id}")
while True:
data = make_api_request(endpoint, headers)
print(f"Data received from API: {data}")
print(f"Total runs found: {data['total_count']}")
check_runs = data["check_runs"]
print("Processing check runs...")
print(check_runs)
runs_in_progress, all_others_passed = process_check_runs(
check_runs, current_run_id
)
runs_in_progress, all_others_passed = process_check_runs(check_runs)
if not runs_in_progress:
break