diff --git a/coverage_comment/github.py b/coverage_comment/github.py index 3d9db89b..186e5330 100644 --- a/coverage_comment/github.py +++ b/coverage_comment/github.py @@ -197,10 +197,10 @@ def create_missing_coverage_annotation(annotation_type: str, file: str, line: in ) -def append_to_environment_file(content: str, filepath: pathlib.Path): +def append_to_file(content: str, filepath: pathlib.Path): with filepath.open(mode="a") as file: file.write(content) def add_job_summary(content: str, github_step_summary: pathlib.Path): - append_to_environment_file(content=content, filepath=github_step_summary) + append_to_file(content=content, filepath=github_step_summary) diff --git a/coverage_comment/main.py b/coverage_comment/main.py index 9cf04ed5..74e5a798 100644 --- a/coverage_comment/main.py +++ b/coverage_comment/main.py @@ -279,7 +279,7 @@ def save_coverage_data_files( markdown_report = coverage_module.generate_coverage_markdown() github.add_job_summary( - content=f"## Coverage report\n{markdown_report}", + content=f"## Coverage report\n\n{markdown_report}", github_step_summary=config.GITHUB_STEP_SUMMARY, ) diff --git a/tests/integration/test_github.py b/tests/integration/test_github.py index f8fc2083..218f216c 100644 --- a/tests/integration/test_github.py +++ b/tests/integration/test_github.py @@ -336,7 +336,11 @@ def test_create_missing_coverage_annotation__annotation_type(capsys): def test_add_job_summary(summary_file): github.add_job_summary( - content="[job summary content]", github_step_summary=summary_file + content="[job summary part 1]\n", github_step_summary=summary_file ) + assert summary_file.read_text() == "[job summary part 1]\n" - assert summary_file.read_text() == "[job summary content]" + github.add_job_summary( + content="[job summary part 2]", github_step_summary=summary_file + ) + assert summary_file.read_text() == "[job summary part 1]\n[job summary part 2]" diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py index 821444cc..91b55d3d 100644 --- a/tests/integration/test_main.py +++ b/tests/integration/test_main.py @@ -366,10 +366,13 @@ def test_action__push__default_branch( See more details and ready-to-copy-paste-markdown at: https://github.com/py-cov-action/foobar/tree/python-coverage-comment-action-data""" assert log == expected - assert "## Coverage report" in summary_file.read_text() - assert "Name" in summary_file.read_text() - assert "Stmts" in summary_file.read_text() - assert "Missing" in summary_file.read_text() + + summary_content = summary_file.read_text() + + assert "## Coverage report" in summary_content + assert "Name" in summary_content + assert "Stmts" in summary_content + assert "Missing" in summary_content def test_action__push__default_branch__private(