Skip to content

Commit 3692275

Browse files
committed
refactor: render passed checks like the step log in the details block
Replace the passed-checks table with a fenced block mirroring the step log layout (group name followed by indented ✔ scope lines), so the success report reads the same as the action log.
1 parent 9beedd7 commit 3692275

2 files changed

Lines changed: 31 additions & 14 deletions

File tree

‎main.py‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -416,18 +416,18 @@ def _markdown_details(results: list[ScopeResult]) -> str:
416416

417417

418418
def _markdown_passed_details(results: list[ScopeResult]) -> str:
419-
"""Render the collapsible section listing which checks passed per scope."""
420-
rows = ["| Scope | Passed checks |", "|---|---|"]
421-
for scope in results:
422-
passed = [c for c in scope.checks if c["status"] == "pass"]
423-
if passed:
424-
links = ", ".join(_rule_markdown_link(c) for c in passed)
425-
else:
426-
links = "\u2014"
427-
rows.append(f"| {scope.label} | {links} |")
428-
return "\n".join(
429-
["<details>", "<summary>Show details</summary>", "", *rows, "", "</details>"]
430-
)
419+
"""Render the collapsible section listing passed checks per scope.
420+
421+
Mirrors the step log layout (group name followed by indented ✔ scope
422+
lines) inside a fenced block so it reads like the action log.
423+
"""
424+
lines = ["<details>", "<summary>Show details</summary>", "", "```text"]
425+
for group_name, scopes in _grouped(results):
426+
lines.append(group_name)
427+
for scope in scopes:
428+
lines.append(f" ✔ {scope.label}")
429+
lines.extend(["```", "", "</details>"])
430+
return "\n".join(lines)
431431

432432

433433
def render_report(results: list[ScopeResult], include_footer: bool = True) -> str:

‎main_test.py‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,25 @@ def test_all_pass(self):
635635
self.assertIn("All checks passed (1 scope)", body)
636636
self.assertIn("<details>", body)
637637
self.assertIn("<summary>Show details</summary>", body)
638-
self.assertIn("| Scope | Passed checks |", body)
639-
self.assertIn("| Branch | CC001 branch |", body)
638+
self.assertIn("```text", body)
639+
self.assertIn("Branch", body)
640+
self.assertIn(" ✔ Branch", body)
641+
642+
def test_all_pass_groups_scopes_like_step_log(self):
643+
results = [
644+
pass_scope("PR title"),
645+
pass_scope("Commit 1/2"),
646+
pass_scope("Commit 2/2"),
647+
pass_scope("Branch"),
648+
pass_scope("Author name"),
649+
pass_scope("Author email"),
650+
]
651+
body = main.render_job_summary(results)
652+
# Group headers in the details block mirror the step log ordering.
653+
self.assertLess(body.index("Commit message"), body.index("Branch"))
654+
self.assertLess(body.index("Branch"), body.index("Author"))
655+
for scope in results:
656+
self.assertIn(f" ✔ {scope.label}", body)
640657

641658
def test_failure_renders_table_with_rule_links(self):
642659
body = main.render_job_summary([fail_scope("Commit 1/1")])

0 commit comments

Comments
 (0)