Skip to content

Commit

Permalink
Add small fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
kieferro committed Jul 11, 2023
1 parent 252fb47 commit dfd29fa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions coverage_comment/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion coverage_comment/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
8 changes: 6 additions & 2 deletions tests/integration/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
11 changes: 7 additions & 4 deletions tests/integration/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit dfd29fa

Please sign in to comment.