MCPcopy Create free account
hub / github.com/apache/tvm / commit_passed_ci

Function commit_passed_ci

ci/scripts/github/update_branch.py:104–135  ·  view source on GitHub ↗

Returns true if all of a commit's statuses are SUCCESS

(commit: dict[str, Any])

Source from the content-addressed store, hash-verified

102
103
104def 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
138def update_branch(user: str, repo: str, sha: str, branch_name: str) -> None:

Callers 1

update_branch.pyFile · 0.85

Calls 3

printFunction · 0.85
allFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…