Skip to content

Commit ab5d0f5

Browse files
committed
fix: explain allowed failures in the legend and share the non-zero join
1 parent 82190c3 commit ab5d0f5

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

‎release_scope/_render.py‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"skipped": "⏭",
2020
"manual": "⏭",
2121
}
22-
_LEGEND: typing.Final = "Legend: ✅ success · ❌ failed · 🔄 running · ⏭ canceled or skipped · ⚠️ needs attention"
22+
_LEGEND: typing.Final = (
23+
"Legend: ✅ success · ❌ failed · 🔄 running · ⏭ canceled or skipped · ⚠️ warning or allowed failure"
24+
)
2325
_ROW_HEADER: typing.Final = ("Tag", "Change", "Jira", "Deployed to", "Failed jobs")
2426
_FAILED, _SKIPPED, _PENDING = 0, 1, 2
2527

@@ -46,6 +48,10 @@ def _plural(count: int, noun: str) -> str:
4648
return f"{count} {noun}" if count == 1 else f"{count} {noun}s"
4749

4850

51+
def _nonzero(separator: str, parts: collections.abc.Iterable[tuple[int, str]]) -> str:
52+
return separator.join(text for count, text in parts if count)
53+
54+
4955
def _table(
5056
header: collections.abc.Sequence[str], rows: collections.abc.Iterable[collections.abc.Sequence[str]]
5157
) -> list[str]:
@@ -88,9 +94,7 @@ def _failure_counts(service: Service) -> str:
8894
jobs: typing.Final = [job for pipeline in pipelines if pipeline for job in pipeline.failed_jobs]
8995
allowed: typing.Final = sum(1 for job in jobs if job.allow_failure)
9096
blocking: typing.Final = len(jobs) - allowed
91-
return " · ".join(
92-
text for count, text in ((blocking, f"❌ {blocking}"), (allowed, f"⚠️ {allowed} allowed")) if count
93-
)
97+
return _nonzero(" · ", [(blocking, f"❌ {blocking}"), (allowed, f"⚠️ {allowed} allowed")])
9498

9599

96100
def _pending(service: Service) -> str:
@@ -170,13 +174,8 @@ def _row(row: Row) -> list[str]:
170174
def _counts(service: Service) -> str:
171175
merge_requests: typing.Final = len({item.iid for row in service.rows for item in row.merge_requests})
172176
commits: typing.Final = sum(1 for row in service.rows if row.kind == "commit")
173-
return ", ".join(
174-
text
175-
for count, text in (
176-
(merge_requests, _plural(merge_requests, "merge request")),
177-
(commits, _plural(commits, "direct commit")),
178-
)
179-
if count
177+
return _nonzero(
178+
", ", [(merge_requests, _plural(merge_requests, "merge request")), (commits, _plural(commits, "direct commit"))]
180179
)
181180

182181

‎tests/test_render.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def test_page_lists_attention_first_and_collapses_up_to_date_services() -> None:
145145
"",
146146
"Collected 2026-09-29 10:15 UTC. Changes run from the commit on `prod` to the head of the default branch.",
147147
"",
148-
"Legend: ✅ success · ❌ failed · 🔄 running · ⏭ canceled or skipped · ⚠️ needs attention",
148+
"Legend: ✅ success · ❌ failed · 🔄 running · ⏭ canceled or skipped · ⚠️ warning or allowed failure",
149149
"",
150150
"| Service | prod | preview | Pending | Failed jobs |",
151151
"|---|---|---|---|---|",

0 commit comments

Comments
 (0)