Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/comment_coverage.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<br>

| &ensp; | 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 %}

Expand Down
4 changes: 2 additions & 2 deletions templates/comment_quality.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<br>

| &ensp; | 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 %}

Expand Down
4 changes: 2 additions & 2 deletions templates/step_summary.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<br>

| &ensp; | 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 %}

Expand Down
30 changes: 29 additions & 1 deletion tests/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 "<!-- diff-cover-action:test-id -->" 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:
Expand Down
Loading