Returns true if all of a commit's statuses are SUCCESS
(commit: dict[str, Any])
| 102 | |
| 103 | |
| 104 | def commit_passed_ci(commit: dict[str, Any]) -> bool: |
| 105 | """ |
| 106 | Returns true if all of a commit's statuses are SUCCESS |
| 107 | """ |
| 108 | statuses = commit["statusCheckRollup"]["contexts"]["nodes"] |
| 109 | |
| 110 | # GitHub Actions statuses are different from external GitHub statuses, so |
| 111 | # unify them into 1 representation |
| 112 | # https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads |
| 113 | unified_statuses = [] |
| 114 | for status in statuses: |
| 115 | if "context" in status: |
| 116 | # Parse non-GHA status |
| 117 | unified_statuses.append((status["context"], status["state"] == "SUCCESS")) |
| 118 | else: |
| 119 | # Parse GitHub Actions item |
| 120 | workflow = status["checkSuite"]["workflowRun"]["workflow"]["name"] |
| 121 | name = f"{workflow} / {status['name']}" |
| 122 | unified_statuses.append((name, status["conclusion"] == "SUCCESS")) |
| 123 | |
| 124 | print(f"Statuses on {commit['oid']}:", json.dumps(unified_statuses, indent=2)) |
| 125 | |
| 126 | # Assert that specific jobs are present in the commit statuses (i.e. don't |
| 127 | # approve if CI was broken and didn't schedule a job) |
| 128 | job_names = {name for name, status in unified_statuses} |
| 129 | for job in EXPECTED_CI_JOBS: |
| 130 | if job not in job_names: |
| 131 | # Did not find expected job name |
| 132 | return False |
| 133 | |
| 134 | passed_ci = all(status for name, status in unified_statuses) |
| 135 | return passed_ci |
| 136 | |
| 137 | |
| 138 | def update_branch(user: str, repo: str, sha: str, branch_name: str) -> None: |
no test coverage detected
searching dependent graphs…