Skip to content

Commit 686e79f

Browse files
authored
fix: release pipeline status checks (#602)
- Fetches jobs from current run and skips them from checks
1 parent e6d156a commit 686e79f

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

.github/workflows/pipeline-release-tag.yml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,38 +89,59 @@ jobs:
8989
import httpx
9090
import sys
9191
92-
url = "https://api.github.com/repos/${{ github.repository }}/commits/tags/${{ needs.setup.outputs.devTag }}/check-runs?per_page=100&page={page}"
92+
check_runs_url = "https://api.github.com/repos/${{ github.repository }}/commits/tags/${{ needs.setup.outputs.devTag }}/check-runs?per_page=100&page={page}"
93+
jobs_url="https://api.github.com/repos/supertokens/supertokens-python/actions/runs/${{ github.run_id }}/jobs"
94+
95+
current_jobs_response = httpx.get(jobs_url).json()
96+
current_job_ids = [job["id"] for job in current_jobs_response["jobs"]]
97+
9398
page = 1
9499
total = 0
95100
96101
status_map = defaultdict(int)
97102
conclusion_map = defaultdict(int)
103+
failures = []
98104
99105
while True:
100-
response = httpx.get(url.format(page=page)).json()
106+
response = httpx.get(check_runs_url.format(page=page)).json()
107+
108+
if len(response["check_runs"]) == 0:
109+
break
110+
111+
for run_info in response["check_runs"]:
112+
# Release pipeline jobs also show up in check-runs
113+
# We skip them from the checks to avoid pipeline failures
114+
if run_info["id"] in current_job_ids:
115+
continue
101116
102-
if len(response["check_runs"]) == 0:
103-
break
117+
if run_info["conclusion"] == "failure":
118+
failures.append(run_info["html_url"])
104119
105-
for run_info in response["check_runs"]:
106-
status_map[run_info["status"]] += 1
107-
conclusion_map[run_info["conclusion"]] += 1
108-
total += 1
120+
status_map[run_info["status"]] += 1
121+
conclusion_map[run_info["conclusion"]] += 1
122+
total += 1
109123
110-
page += 1
124+
page += 1
111125
126+
print(f"{page=}")
112127
print(f"{total=}")
113-
print(dict(status_map))
114-
print(dict(conclusion_map))
128+
print("Status Map =", dict(status_map))
129+
print("Conclusion Map =", dict(conclusion_map))
130+
print()
115131
132+
# Possible values (from docs):
133+
# [completed, action_required, cancelled, failure, neutral, skipped, stale, success,
134+
# timed_out, in_progress, queued, requested, waiting, pending]
116135
if status_map["completed"] < total:
117136
print("Some checks not completed.")
118-
print(dict(status_map))
137+
print(failures)
119138
sys.exit(1)
120139
121-
if conclusion_map["success"] < total:
140+
# Possible values (from testing):
141+
# None, success, skipped, failure
142+
if conclusion_map.get("failure") > 0:
122143
print("Some checks not successful.")
123-
print(dict(conclusion_map))
144+
print(failures)
124145
sys.exit(1)
125146
126147
EOF

0 commit comments

Comments
 (0)