diff --git a/templates/comment_coverage.md.j2 b/templates/comment_coverage.md.j2 index 4b9783c..d1e26fd 100644 --- a/templates/comment_coverage.md.j2 +++ b/templates/comment_coverage.md.j2 @@ -30,8 +30,8 @@
|   | File | Coverage | Uncovered Lines | -|:---:|:---|---:|:---| -{% for f in report.files | sort(attribute='percent_covered') %} +|:---:|:---|---:|:---|{% +for f in report.files | sort(attribute='percent_covered') %} | {{ f.percent_covered | status_icon }} | `{{ f.path }}` | {{ "%.1f" | format(f.percent_covered) }}% | {{ f.violation_lines[:10] | join(', ') if f.violation_lines else '—' }}{% if f.violation_lines | length > 10 %} (+{{ f.violation_lines | length - 10 }} more){% endif %} | {% endfor %} diff --git a/templates/comment_quality.md.j2 b/templates/comment_quality.md.j2 index d11faea..57c8e6f 100644 --- a/templates/comment_quality.md.j2 +++ b/templates/comment_quality.md.j2 @@ -30,8 +30,8 @@
|   | File | Quality | Violation Lines | -|:---:|:---|---:|:---| -{% for f in report.files | sort(attribute='percent_covered') %} +|:---:|:---|---:|:---|{% +for f in report.files | sort(attribute='percent_covered') %} | {{ f.percent_covered | status_icon }} | `{{ f.path }}` | {{ "%.1f" | format(f.percent_covered) }}% | {{ f.violation_lines[:10] | join(', ') if f.violation_lines else '—' }}{% if f.violation_lines | length > 10 %} (+{{ f.violation_lines | length - 10 }} more){% endif %} | {% endfor %} diff --git a/templates/step_summary.md.j2 b/templates/step_summary.md.j2 index 5dc8e08..f08559c 100644 --- a/templates/step_summary.md.j2 +++ b/templates/step_summary.md.j2 @@ -20,8 +20,8 @@
|   | File | {{ "Coverage" if mode == "coverage" else "Quality" }} | -|:---:|:---|---:| -{% for f in report.files | sort(attribute='percent_covered') %} +|:---:|:---|---:|{% +for f in report.files | sort(attribute='percent_covered') %} | {{ f.percent_covered | status_icon }} | `{{ f.path }}` | {{ "%.1f" | format(f.percent_covered) }}% | {% endfor %} diff --git a/tests/test_comment.py b/tests/test_comment.py index 4c8ffa0..f57e77a 100644 --- a/tests/test_comment.py +++ b/tests/test_comment.py @@ -74,7 +74,7 @@ def test_is_fork_pr_missing_file() -> None: assert _is_fork_pr("/nonexistent/event.json", "owner/repo") is False -def test_render_comment_body() -> None: +def test_render_comment_body_coverage() -> None: report = Report( report_name="XML", diff_name="origin/main...HEAD", @@ -98,6 +98,34 @@ def test_render_comment_body() -> None: assert "90.0%" in body assert "threshold-passed-success" in body assert "src/foo.py" in body + assert "|:---:|:---|---:|:---|\n| 🟡 | `src/foo.py` | 85.0% | 13, 27 |" in body + + +def test_render_comment_body_quality() -> None: + report = Report( + report_name="XML", + diff_name="origin/main...HEAD", + files=[ + FileReport(path="src/foo.py", percent_covered=85.0, violation_lines=[13, 27]), + ], + total_num_lines=10, + total_num_violations=2, + total_percent_covered=95.0, + ) + body = _render_comment_body( + report=report, + mode="quality", + fail_under=80.0, + threshold_met=True, + identifier="test-id", + title="", + md_report_content="", + ) + assert "" in body + assert "95.0%" in body + assert "threshold-passed-success" in body + assert "src/foo.py" in body + assert "|:---:|:---|---:|:---|\n| 🟡 | `src/foo.py` | 85.0% | 13, 27 |" in body def test_render_comment_body_with_title() -> None: