Repository: py-cov-action/python-coverage-comment-action
Pull request #337 (2024-01-02 09:47:05)

Small fixes to the comment template

github-actions[bot]: [End-to-end public repo](https://github.com/mihcaojwe/python-coverage-comment-action-end-to-end-337-public)

Other commands:

- Have an admin approve a review with /e2e to trigger end-to-end tests on external contributions
- Comment with /invite to invite the author & admins to the end-to-end private repo


Patch:
diff --git a/coverage_comment/template_files/comment.md.j2 b/coverage_comment/template_files/comment.md.j2
index 650ade2..518a318 100644
--- a/coverage_comment/template_files/comment.md.j2
+++ b/coverage_comment/template_files/comment.md.j2
@@ -109,7 +109,8 @@
 
 {# Individual file report #}
 {%- block coverage_by_file -%}
-{%- if not files -%}
+{%- if not files %}
+
 _This PR does not seem to contain any modification to coverable code._
 {%- else -%}
 <details><summary>Click to see where and how coverage changed</summary><table><thead>
@@ -246,19 +247,20 @@ _This PR does not seem to contain any modification to coverable code._
 > [!NOTE]
 > The report is truncated to {{ max_files }} files out of {{ count_files }}. To see the full report, please visit the workflow summary page.
 
-{% endif -%}
+{% endif %}
 
-{%- endif -%}
-{%- endblock coverage_by_file -%}
+{%- block footer %}
 
-{%- block footer -%}
 <sub>
 
 This report was generated by [python-coverage-comment-action](https://github.com/py-cov-action/python-coverage-comment-action)
 
 </sub>
-
-{%- endblock footer -%}
 </details>
 
+{% endblock footer -%}
+
+{%- endif -%}
+{%- endblock coverage_by_file %}
+
 {{ marker -}}


Test patch:
diff --git a/tests/unit/test_template.py b/tests/unit/test_template.py
index c9ebd89..51880ec 100644
--- a/tests/unit/test_template.py
+++ b/tests/unit/test_template.py
@@ -92,11 +92,16 @@ def test_template(coverage_obj, diff_coverage_obj):
 <td align="center"><a href="https://github.com/org/repo/pull/5/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="This PR adds 10 statements to the whole project. The file did not seem to exist on the base branch." src="https://img.shields.io/badge/10-%28%2B10%29-007ec6.svg"></a></td><td align="center"><a href="https://github.com/org/repo/pull/5/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="This PR adds 4 statements missing coverage to the whole project. The file did not seem to exist on the base branch." src="https://img.shields.io/badge/4-%28%2B4%29-red.svg"></a></td><td align="center"><a href="https://github.com/org/repo/pull/5/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="The coverage rate of the whole project is 60% (6/10). The file did not seem to exist on the base branch." src="https://img.shields.io/badge/60%25-%286/10%29-orange.svg"></a></td><td align="center"><a href="https://github.com/org/repo/pull/5/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="In this PR, 4 new statements are added to the whole project, 2 of which are covered (50%)." src="https://img.shields.io/badge/50%25-%282/4%29-orange.svg"></a></td><td>&nbsp;</td>
 </tr>
 </tfoot>
-</table><sub>
+</table>
+
+<sub>
 
 This report was generated by [python-coverage-comment-action](https://github.com/py-cov-action/python-coverage-comment-action)
 
-</sub></details>
+</sub>
+</details>
+
+
 
 <!-- foo -->"""
     assert result == expected
@@ -218,11 +223,16 @@ def test_template_full(make_coverage, make_coverage_and_diff):
 <td align="center"><a href="https://github.com/org/repo/pull/12/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="This PR adds 2 to the number of statements in the whole project, taking it from 19 to 21." src="https://img.shields.io/badge/21-%28%2B2%29-007ec6.svg"></a></td><td align="center"><a href="https://github.com/org/repo/pull/12/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="This PR adds 1 to the number of statements missing coverage in the whole project, taking it from 3 to 4." src="https://img.shields.io/badge/4-%28%2B1%29-red.svg"></a></td><td align="center"><a href="https://github.com/org/repo/pull/12/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="This PR removes 3.26 percentage points from the coverage rate in the whole project, taking it from 84.21% (16/19) to 80.95% (17/21)." src="https://img.shields.io/badge/80%25-%2816/19%20%3E%2017/21%29-red.svg"></a></td><td align="center"><a href="https://github.com/org/repo/pull/12/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="In this PR, 6 new statements are added to the whole project, 2 of which are covered (33.33%)." src="https://img.shields.io/badge/33%25-%282/6%29-red.svg"></a></td><td>&nbsp;</td>
 </tr>
 </tfoot>
-</table><sub>
+</table>
+
+<sub>
 
 This report was generated by [python-coverage-comment-action](https://github.com/py-cov-action/python-coverage-comment-action)
 
-</sub></details>
+</sub>
+</details>
+
+
 
 <!-- foo -->"""
     print(result)
@@ -267,11 +277,16 @@ def test_template__no_previous(coverage_obj_no_branch, diff_coverage_obj):
 <td align="center"><a href="https://github.com/org/repo/pull/3/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="This PR adds 8 statements to the whole project. The file did not seem to exist on the base branch." src="https://img.shields.io/badge/8-%28%2B8%29-007ec6.svg"></a></td><td align="center"><a href="https://github.com/org/repo/pull/3/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="This PR adds 4 statements missing coverage to the whole project. The file did not seem to exist on the base branch." src="https://img.shields.io/badge/4-%28%2B4%29-red.svg"></a></td><td align="center"><a href="https://github.com/org/repo/pull/3/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="The coverage rate of the whole project is 50% (4/8). The file did not seem to exist on the base branch." src="https://img.shields.io/badge/50%25-%284/8%29-red.svg"></a></td><td align="center"><a href="https://github.com/org/repo/pull/3/files#diff-4b0bf2efa3367c0072ac2bf1e234e703dc46b47aaa4fe9d3b01737b1a15752b1"><img title="In this PR, 4 new statements are added to the whole project, 2 of which are covered (50%)." src="https://img.shields.io/badge/50%25-%282/4%29-red.svg"></a></td><td>&nbsp;</td>
 </tr>
 </tfoot>
-</table><sub>
+</table>
+
+<sub>
 
 This report was generated by [python-coverage-comment-action](https://github.com/py-cov-action/python-coverage-comment-action)
 
-</sub></details>
+</sub>
+</details>
+
+
 
 <!-- foo -->"""
     print(result)