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+
4955def _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
96100def _pending (service : Service ) -> str :
@@ -170,13 +174,8 @@ def _row(row: Row) -> list[str]:
170174def _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
0 commit comments