Skip to content

Commit 5e6e5ba

Browse files
fix(ci): exclude cancelled jobs from pr-test-summary failed count (#1558)
## Summary - `failed` was computed as "anything not passed or skipped", so cancelled jobs (e.g. downstream jobs queued when one job fails) were counted as failures. - Fix: only count jobs with `conclusion in ("failure", "timed_out")`. Closes #1223 Authors: - Ramakrishna Prabhu (https://github.com/ramakrishnap-nv) Approvers: - Trevor McKay (https://github.com/tmckayus) - James Lamb (https://github.com/jameslamb) URL: #1558
1 parent d117b8e commit 5e6e5ba

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

‎ci/utils/pr_test_summary.py‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,21 @@ def _add(test_id):
131131
return failed[:_MAX_TESTS]
132132

133133

134-
def _build_body(failed, passed, skipped, job_analysis):
134+
def _build_body(failed, passed, skipped, cancelled, job_analysis):
135135
lines = [_MARKER, "## CI Test Summary", ""]
136136
if not failed:
137-
lines.append(f"✅ All {len(passed)} test job(s) passed.")
137+
if cancelled:
138+
parts = [f"✅ {len(passed)} passed"]
139+
if skipped:
140+
parts.append(f"{len(skipped)} skipped")
141+
parts.append(f"{len(cancelled)} cancelled / not completed")
142+
lines.append(" · ".join(parts))
143+
else:
144+
lines.append(f"✅ All {len(passed)} test job(s) passed.")
138145
else:
139146
lines.append(
140147
f"**{len(failed)} failed** · {len(passed)} passed · {len(skipped)} skipped"
148+
+ (f" · {len(cancelled)} cancelled" if cancelled else "")
141149
)
142150
for job in failed:
143151
tests = job_analysis[job["id"]]
@@ -177,13 +185,20 @@ def main():
177185

178186
passed = [j for j in test_jobs if j["conclusion"] == "success"]
179187
skipped = [j for j in test_jobs if j["conclusion"] == "skipped"]
180-
failed = [j for j in test_jobs if j not in passed and j not in skipped]
188+
failed = [
189+
j for j in test_jobs if j["conclusion"] in ("failure", "timed_out")
190+
]
191+
cancelled = [
192+
j
193+
for j in test_jobs
194+
if j not in passed and j not in skipped and j not in failed
195+
]
181196

182197
job_analysis = {
183198
job["id"]: _analyze_job_log(job["id"], repo, token) for job in failed
184199
}
185200

186-
body = _build_body(failed, passed, skipped, job_analysis)
201+
body = _build_body(failed, passed, skipped, cancelled, job_analysis)
187202

188203
comments = list(
189204
_paginate(f"/repos/{repo}/issues/{pr_number}/comments", token)

0 commit comments

Comments
 (0)