Skip to content

Commit bbba5cd

Browse files
committed
feat: add CodSpeed-style pass/fail stats to the report header
The status line now reads '❌ 2 failures · ✅ 4 passed (6 scopes)' on failure and '✅ 11 passed (11 scopes)' on success, mirroring the compact emoji-plus-count style of CodSpeed reports so the pass ratio is visible without scanning the table.
1 parent 257ae28 commit bbba5cd

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

main.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,29 +475,31 @@ def _markdown_passed_details(results: list[ScopeResult]) -> str:
475475
def render_report(results: list[ScopeResult], include_footer: bool = True) -> str:
476476
"""Render the Markdown report shared by the job summary and PR comment.
477477
478-
The report opens with the plain title line followed by the status line:
479-
``✅ All checks passed (N scopes)`` on success, or the failure count on
480-
failure, followed by a scope table with rule links and collapsible
481-
failure details.
478+
The report opens with the plain title line followed by a CodSpeed-style
479+
status line: ``✅ **N passed** (N scopes)`` on success, or
480+
``❌ **N failures** · ✅ **M passed** (N scopes)`` on failure, followed
481+
by a scope table with rule links and collapsible details.
482482
"""
483483
if all(scope.status == "pass" for scope in results):
484484
scopes = "scope" if len(results) == 1 else "scopes"
485485
lines = [
486486
REPORT_TITLE,
487487
"",
488-
f"✅ All checks passed ({len(results)} {scopes})",
488+
f"✅ **{len(results)} passed** ({len(results)} {scopes})",
489489
"",
490490
_markdown_passed_details(results),
491491
]
492492
return "\n".join(lines)
493493

494494
failures = _failure_count(results)
495495
unit = "failure" if failures == 1 else "failures"
496+
passed = sum(1 for scope in results if scope.status == "pass")
496497
scopes = "scope" if len(results) == 1 else "scopes"
497498
lines = [
498499
REPORT_TITLE,
499500
"",
500-
f"❌ **{failures} {unit}** across {len(results)} {scopes}",
501+
f"❌ **{failures} {unit}** · ✅ **{passed} passed** "
502+
f"({len(results)} {scopes})",
501503
"",
502504
_markdown_table(results),
503505
"",

main_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ class TestRenderJobSummary(unittest.TestCase):
632632
def test_all_pass(self):
633633
body = main.render_job_summary([pass_scope("Branch", value="main")])
634634
self.assertTrue(body.startswith(main.REPORT_TITLE))
635-
self.assertIn("All checks passed (1 scope)", body)
635+
self.assertIn("✅ **1 passed** (1 scope)", body)
636636
self.assertIn("<details>", body)
637637
self.assertIn("<summary>Show details</summary>", body)
638638
self.assertIn("```text", body)
@@ -669,7 +669,7 @@ def test_all_pass_without_value_shows_plain_label(self):
669669
def test_failure_renders_table_with_rule_links(self):
670670
body = main.render_job_summary([fail_scope("Commit 1/1")])
671671
self.assertTrue(body.startswith(main.REPORT_TITLE))
672-
self.assertIn("**1 failure** across 1 scope", body)
672+
self.assertIn("**1 failure** · ✅ **0 passed** (1 scope)", body)
673673
self.assertIn("| Scope | Checked value | Failed checks | Result |", body)
674674
self.assertIn(
675675
"| Commit 1/1 | `bad message` | "
@@ -704,14 +704,14 @@ def test_all_pass_matches_job_summary(self):
704704
summary = main.render_job_summary([pass_scope("Branch")])
705705
self.assertEqual(comment, summary)
706706
self.assertTrue(comment.startswith(main.REPORT_TITLE))
707-
self.assertIn("All checks passed (1 scope)", comment)
707+
self.assertIn("✅ **1 passed** (1 scope)", comment)
708708

709709
def test_failure_matches_job_summary(self):
710710
comment = main.render_pr_comment([fail_scope("Commit 1/1")])
711711
summary = main.render_job_summary([fail_scope("Commit 1/1")])
712712
self.assertEqual(comment, summary)
713713
self.assertTrue(comment.startswith(main.REPORT_TITLE))
714-
self.assertIn("**1 failure** across 1 scope", comment)
714+
self.assertIn("**1 failure** · ✅ **0 passed** (1 scope)", comment)
715715
self.assertIn("| Scope | Checked value | Failed checks | Result |", comment)
716716

717717

@@ -741,7 +741,7 @@ def test_success_writes_policy_report(self):
741741
self.assertEqual(rc, 0)
742742
with open(summary_path, encoding="utf-8") as file_obj:
743743
content = file_obj.read()
744-
self.assertIn("All checks passed", content)
744+
self.assertIn("✅ **1 passed** (1 scope)", content)
745745

746746
def test_failure_returns_nonzero(self):
747747
summary_path = os.path.join(tempfile.mkdtemp(), "summary.txt")

0 commit comments

Comments
 (0)