Skip to content

Commit 3fa0c58

Browse files
committed
feat: show checked values in the failure table
The scope table now carries a 'Checked value' column (mirroring the success details), so a failing report answers what exactly was checked without expanding the failure details.
1 parent 2597572 commit 3fa0c58

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

‎main.py‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,25 @@ def _failure_count(results: list[ScopeResult]) -> int:
382382

383383

384384
def _markdown_table(results: list[ScopeResult]) -> str:
385-
"""Render the scope/result table shared by summary and PR comment."""
386-
rows = ["| Scope | Failed checks | Result |", "|---|---|---|"]
385+
"""Render the scope/result table shared by summary and PR comment.
386+
387+
The checked-value column mirrors what the success details show per
388+
scope, so a failing table still answers "what exactly was checked".
389+
"""
390+
rows = [
391+
"| Scope | Checked value | Failed checks | Result |",
392+
"|---|---|---|---|",
393+
]
387394
for scope in results:
395+
value = _scope_value(scope)
396+
value_display = f"`{value}`" if value else "\u2014"
388397
if scope.status == "pass":
389-
rows.append(f"| {scope.label} | \u2014 | \u2705 |")
398+
rows.append(f"| {scope.label} | {value_display} | \u2014 | \u2705 |")
390399
else:
391400
links = " \u00b7 ".join(
392401
_rule_markdown_link(check) for check in scope.failures
393402
)
394-
rows.append(f"| {scope.label} | {links} | \u274c |")
403+
rows.append(f"| {scope.label} | {value_display} | {links} | \u274c |")
395404
return "\n".join(rows)
396405

397406

‎main_test.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,10 @@ 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))
672672
self.assertIn("**1 failure** across 1 scope", body)
673-
self.assertIn("| Scope | Failed checks | Result |", body)
673+
self.assertIn("| Scope | Checked value | Failed checks | Result |", body)
674674
self.assertIn(
675-
"| Commit 1/1 | [CC001 message](https://commit-check.com/rules/#cc001) | ❌ |",
675+
"| Commit 1/1 | `bad message` | "
676+
"[CC001 message](https://commit-check.com/rules/#cc001) | ❌ |",
676677
body,
677678
)
678679
self.assertIn("<details>", body)
@@ -682,7 +683,7 @@ def test_failure_renders_table_with_rule_links(self):
682683

683684
def test_pass_scope_renders_checkmark(self):
684685
body = main.render_job_summary([pass_scope("Branch"), fail_scope("Commit 1/1")])
685-
self.assertIn("| Branch | — | ✅ |", body)
686+
self.assertIn("| Branch | — | — | ✅ |", body)
686687

687688

688689
class TestRenderPrComment(unittest.TestCase):
@@ -699,7 +700,7 @@ def test_failure_matches_job_summary(self):
699700
self.assertEqual(comment, summary)
700701
self.assertTrue(comment.startswith(main.REPORT_TITLE))
701702
self.assertIn("**1 failure** across 1 scope", comment)
702-
self.assertIn("| Scope | Failed checks | Result |", comment)
703+
self.assertIn("| Scope | Checked value | Failed checks | Result |", comment)
703704

704705

705706
class TestBuildResultBody(unittest.TestCase):
@@ -740,7 +741,7 @@ def test_failure_returns_nonzero(self):
740741
self.assertEqual(rc, 1)
741742
with open(summary_path, encoding="utf-8") as file_obj:
742743
content = file_obj.read()
743-
self.assertIn("| Scope | Failed checks | Result |", content)
744+
self.assertIn("| Scope | Checked value | Failed checks | Result |", content)
744745
self.assertIn("❌", content)
745746

746747

@@ -833,7 +834,7 @@ def test_creates_comment_with_rendered_body(self):
833834
self.assertEqual(mock_pull_request.create_comment.call_count, 1)
834835
body = mock_pull_request.create_comment.call_args[1]["body"]
835836
self.assertTrue(body.startswith(main.REPORT_TITLE))
836-
self.assertIn("| Scope | Failed checks | Result |", body)
837+
self.assertIn("| Scope | Checked value | Failed checks | Result |", body)
837838

838839
def test_updates_existing_comment_when_changed(self):
839840
old_comment = MagicMock(body="# Commit-Check ❌ 0 failures")

0 commit comments

Comments
 (0)