Repository: py-cov-action/python-coverage-comment-action
Pull request #134 (2023-02-05 13:22:07)

Add new features in README


Patch:
diff --git a/README.md b/README.md
index 7f96904..703b6ef 100644
--- a/README.md
+++ b/README.md
@@ -4,10 +4,11 @@
 
 ## Presentation
 
-Publish diff coverage report as PR comment, and create a coverage badge to
-display on the readme.
+Publish diff coverage report as PR comment, create a coverage badge to
+display on the readme, and a browsable HTML coverage report (hosted in a dedicated
+branch of the repository)
 
-See example at: https://github.com/py-cov-action/python-coverage-comment-action-v3-example
+[See this action in action](https://github.com/py-cov-action/python-coverage-comment-action-v3-example)
 
 ## What does it do?
 
@@ -25,12 +26,12 @@ of coverage rate attributed to this PR, as well as the rate of coverage
 for lines that this PR introduces. There's also a small analysis for each
 file in a collapsed block.
 
-See: https://github.com/py-cov-action/python-coverage-comment-action-v3-example/pull/2#issuecomment-1244431724
+See [an example](https://github.com/py-cov-action/python-coverage-comment-action-v3-example/pull/2#issuecomment-1244431724).
 
 ### Default branch mode
 
 On repository's default branch, it will extract the coverage rate and create
-files that will be stored on a dedicated orphan branch in the repository.
+files that will be stored on a dedicated independant branch in your repository.
 
 These files include:
 
@@ -39,8 +40,10 @@ These files include:
   repository is public to customize the look of your badge
 - Another `json` file used internally by the action to report on coverage
   evolution (does a PR make the coverage go up or down?)
+- A short file-by-file coverage report embedded directy into the branch's README
+- The full HTML coverage report and links to make this report browsable
 
-See: https://github.com/py-cov-action/python-coverage-comment-action-v3-example
+See [an example](https://github.com/py-cov-action/python-coverage-comment-action-v3-example)
 
 ## Usage
 
@@ -284,7 +287,7 @@ jobs:
 
 By default, comments are generated from a
 [Jinja](https://jinja.palletsprojects.com) template that you can read
-[here](https://github.com/py-cov-action/python-coverage-comment-action/blob/v3/coverage_comment/template_files/comment.md.j2).
+[here](https://github.com/py-cov-action/python-coverage-comment-action/blob/v2/coverage_comment/default.md.j2).
 
 If you want to change this template, you can set ``COMMENT_TEMPLATE``. This is
 an advanced usage, so you're likely to run into more road bumps.
@@ -323,8 +326,8 @@ coverage (percentage) of the whole project from the PR build:
 
 # Other topics
 ## Pinning
-On the examples above, the version was set to `v2` (a branch). You can also pin
-a specific version such as `v2.0.0` (a tag). There are still things left to
+On the examples above, the version was set to `v3` (a branch). You can also pin
+a specific version such as `v3.0.0` (a tag). There are still things left to
 figure out in how to manage releases and version. If you're interested, please
 open an issue to discuss this.
 
@@ -336,9 +339,9 @@ version to an exact tag, and use dependabot to update it regularily.
 This action is tested with 100% coverage. That said, coverage isn't all, and
 there may be a lot of remaining issues :)
 
-I'm not prioritizing maintenance on this action, but I'll do my best to assist
-questions and PRs. Feature requests are most likely not to be taken but if
-you're ready to do a PR, I'll gladly work with you.
+We accept Pull Requests (for bug fixes and previously-discussed features), and bug
+reports. For feature requests, this might depend on how much time we have on our hands
+at the moment, and how well you manage to sell it but don't get your hopes too high.
 
 ## Generic coverage
 
diff --git a/coverage_comment/communication.py b/coverage_comment/communication.py
index 6a9b805..abacd31 100644
--- a/coverage_comment/communication.py
+++ b/coverage_comment/communication.py
@@ -1,34 +1,97 @@
 import pathlib
 
-from coverage_comment import files, template
+from coverage_comment import files
+
+README_CONTENTS = """
+# Coverage data
+
+This branch is just here to hold coverage data. It's part of the
+[python-coverage-comment-action](https://github.com/marketplace/actions/python-coverage-comment)
+GitHub Action.
+
+Below are examples of the badges you can use in your main branch `README` file.
+
+### Direct image
+
+[![Coverage badge]({direct_image_url})]({readme_url})
+
+This is the one to use if your repository is private or if you don't want to customize anything.
+""".strip()
+
+PUBLIC_README_CONTENTS = """
+### [Shields.io](https://shields.io) Json Endpoint
+
+[![Coverage badge]({endpoint_image_url})]({readme_url})
+
+Using this one will allow you to [customize](https://shields.io/endpoint) the look of your badge.
+It won't work with private repositories. It won't be refreshed more than once per five minutes.
+
+### [Shields.io](https://shields.io) Dynamic Badge
+
+[![Coverage badge]({dynamic_image_url})]({readme_url})
+
+This one will always be the same color. It won't work for private repos. I'm not even sure why we included it.
+""".strip()
+
+LOG_CONTENTS = """You can use the following URLs to display your badge:
+
+Badge SVG available at:
+    {direct_image_url}""".strip()
+
+PUBLIC_LOG_CONTENTS = """
+Badge from shields endpoint is easier to customize but doesn't work with private repo:
+    {endpoint_image_url}
+
+Badge from shields dynamic url (less useful but you never know):
+    {dynamic_image_url}""".strip()
+
+LOG_CONCLUSION = """
+See more details and ready-to-copy-paste-markdown at {readme_url}""".strip()
 
 
 def get_readme_and_log(
     image_urls: files.ImageURLs,
     readme_url: str,
-    html_report_url: str,
-    markdown_report: str,
     is_public: bool,
 ) -> tuple[files.FileWithPath, str]:
-    readme_markdown = template.get_readme_markdown(
-        is_public=is_public,
-        readme_url=readme_url,
-        markdown_report=markdown_report,
-        html_report_url=html_report_url,
-        direct_image_url=image_urls["direct"],
-        endpoint_image_url=image_urls["endpoint"],
-        dynamic_image_url=image_urls["dynamic"],
-    )
-    log_message = template.get_log_message(
-        is_public=is_public,
-        readme_url=readme_url,
-        html_report_url=html_report_url,
-        direct_image_url=image_urls["direct"],
-        endpoint_image_url=image_urls["endpoint"],
-        dynamic_image_url=image_urls["dynamic"],
-    )
+    """
+    The text we display in the GitHub Actions Log, and what we write in the
+    branch readme when initializing the coverage data branch is quite similar.
+    This function generate both chunks of text with the hope that they'll stay
+    in sync.
+    """
+    readme_contents_parts = [
+        README_CONTENTS.format(
+            readme_url=readme_url,
+            direct_image_url=image_urls["direct"],
+        )
+    ]
+    if is_public:
+        readme_contents_parts.append(
+            PUBLIC_README_CONTENTS.format(
+                readme_url=readme_url,
+                endpoint_image_url=image_urls["endpoint"],
+                dynamic_image_url=image_urls["dynamic"],
+            )
+        )
     readme = files.FileWithPath(
         path=pathlib.Path("README.md"),
-        contents=readme_markdown,
+        contents="\n\n".join(readme_contents_parts),
     )
+
+    log_message_parts = [
+        LOG_CONTENTS.format(direct_image_url=image_urls["direct"]),
+    ]
+
+    if is_public:
+        public_part = PUBLIC_LOG_CONTENTS.format(
+            endpoint_image_url=image_urls["endpoint"],
+            dynamic_image_url=image_urls["dynamic"],
+        )
+        log_message_parts.append(public_part)
+
+    log_message_parts.append(LOG_CONCLUSION.format(readme_url=readme_url))
+
+    log_message = "\n\n".join(log_message_parts)
+
     return readme, log_message
diff --git a/coverage_comment/coverage.py b/coverage_comment/coverage.py
index bf88879..e9e259e 100644
--- a/coverage_comment/coverage.py
+++ b/coverage_comment/coverage.py
@@ -90,14 +90,6 @@ def get_coverage_info(merge: bool) -> Coverage:
     return extract_info(json.loads(json_coverage))
 
 
-def generate_coverage_html_files() -> None:
-    subprocess.run("coverage", "html", "--skip-empty")
-
-
-def generate_coverage_markdown() -> str:
-    return subprocess.run("coverage", "report", "--format=markdown", "--show-missing")
-
-
 def extract_info(data) -> Coverage:
     """
     {
diff --git a/coverage_comment/template_files/comment.md.j2 b/coverage_comment/default.md.j2
similarity index 100%
rename from coverage_comment/template_files/comment.md.j2
rename to coverage_comment/default.md.j2
diff --git a/coverage_comment/files.py b/coverage_comment/files.py
index 887bcbf..ef321f4 100644
--- a/coverage_comment/files.py
+++ b/coverage_comment/files.py
@@ -11,7 +11,7 @@ from typing import TypedDict
 
 import httpx
 
-from coverage_comment import badge, coverage
+from coverage_comment import badge
 
 ENDPOINT_PATH = pathlib.Path("endpoint.json")
 DATA_PATH = pathlib.Path("data.json")
@@ -21,7 +21,7 @@ BADGE_PATH = pathlib.Path("badge.svg")
 @dataclasses.dataclass
 class FileWithPath:
     path: pathlib.Path
-    contents: str | None
+    contents: str
 
 
 def compute_files(
@@ -78,12 +78,3 @@ def get_urls(url_getter: Callable) -> ImageURLs:
         "endpoint": badge.get_endpoint_url(endpoint_url=url_getter(path=ENDPOINT_PATH)),
         "dynamic": badge.get_dynamic_url(endpoint_url=url_getter(path=ENDPOINT_PATH)),
     }
-
-
-def get_coverage_html_files() -> FileWithPath:
-    coverage.generate_coverage_html_files()
-    path = pathlib.Path("htmlcov")
-    # Coverage will create a .gitignore if the htmlcov dir didn't exist before,
-    # so we may or may not have one.
-    (path / ".gitignore").unlink(missing_ok=True)
-    return FileWithPath(path=path, contents=None)
diff --git a/coverage_comment/main.py b/coverage_comment/main.py
index 8278414..ba0fefa 100644
--- a/coverage_comment/main.py
+++ b/coverage_comment/main.py
@@ -81,7 +81,7 @@ def action(
             )
         else:
             # event_name == "push"
-            return save_coverage_data_files(
+            return save_badge(
                 config=config,
                 coverage=coverage,
                 github_session=github_session,
@@ -119,11 +119,11 @@ def generate_comment(
         previous_coverage = files.parse_datafile(contents=previous_coverage_data_file)
 
     try:
-        comment = template.get_comment_markdown(
+        comment = template.get_markdown_comment(
             coverage=coverage,
             diff_coverage=diff_coverage,
             previous_coverage_rate=previous_coverage,
-            base_template=template.read_template_file("comment.md.j2"),
+            base_template=template.read_template_file(),
             custom_template=config.COMMENT_TEMPLATE,
         )
     except template.MissingMarker:
@@ -234,7 +234,7 @@ def post_comment(config: settings.Config, github_session: httpx.Client) -> int:
     return 0
 
 
-def save_coverage_data_files(
+def save_badge(
     config: settings.Config,
     coverage: coverage_module.Coverage,
     github_session: httpx.Client,
@@ -253,44 +253,30 @@ def save_coverage_data_files(
         log.info("Skipping badge save as we're not on the default branch")
         return 0
 
-    log.info("Computing coverage files & badge")
-    all_files = files.compute_files(
+    log.info("Saving coverage files & badge into the repository")
+    files_to_save = files.compute_files(
         line_rate=coverage.info.percent_covered,
         minimum_green=config.MINIMUM_GREEN,
         minimum_orange=config.MINIMUM_ORANGE,
         http_session=http_session,
     )
-
     is_public = repo_info.is_public()
-    if is_public:
-        log.info("Generating HTML coverage report")
-        all_files.append(files.get_coverage_html_files())
-
-    markdown_report = coverage_module.generate_coverage_markdown()
-
     url_getter = functools.partial(
-        storage.get_raw_file_url,
+        storage.get_file_url,
         is_public=is_public,
         repository=config.GITHUB_REPOSITORY,
         branch=config.COVERAGE_DATA_BRANCH,
     )
-    readme_url = storage.get_repo_file_url(
-        branch=config.COVERAGE_DATA_BRANCH,
-        repository=config.GITHUB_REPOSITORY,
-    )
-    html_report_url = storage.get_html_report_url(
-        branch=config.COVERAGE_DATA_BRANCH,
-        repository=config.GITHUB_REPOSITORY,
-    )
     readme_file, log_message = communication.get_readme_and_log(
-        is_public=is_public,
-        readme_url=readme_url,
+        readme_url=storage.get_readme_url(
+            branch=config.COVERAGE_DATA_BRANCH,
+            repository=config.GITHUB_REPOSITORY,
+        ),
         image_urls=files.get_urls(url_getter=url_getter),
-        html_report_url=html_report_url,
-        markdown_report=markdown_report,
+        is_public=is_public,
     )
     storage.upload_files(
-        files=all_files,
+        files=files_to_save,
         git=git,
         branch=config.COVERAGE_DATA_BRANCH,
         initial_file=readme_file,
diff --git a/coverage_comment/storage.py b/coverage_comment/storage.py
index 965d30a..72303c5 100644
--- a/coverage_comment/storage.py
+++ b/coverage_comment/storage.py
@@ -97,10 +97,8 @@ def upload_files(
                 initial_file=initial_file,
             )
 
-        for file in files + [initial_file]:
-            log.debug(f"Adding {file}")
-            if file.contents is not None:
-                file.path.write_text(file.contents)
+        for file in files:
+            file.path.write_text(file.contents)
             git.add(str(file.path))
 
         try:
@@ -136,7 +134,7 @@ def get_datafile_contents(
     return base64.b64decode(response.content).decode()
 
 
-def get_raw_file_url(
+def get_file_url(
     repository: str,
     branch: str,
     path: pathlib.Path,
@@ -159,26 +157,8 @@ def get_raw_file_url(
     # seconds.
 
 
-def get_repo_file_url(repository: str, branch: str, path: str = "/") -> str:
-    """
-    Computes the GitHub Web UI URL for a given path:
-    If the path is empty or ends with a slash, it will be interpreted as a folder,
-    so the URL will point to the page listing files and displaying the README.
-    Otherwise, the URL will point to the page displaying the file contents within
-    the UI.
-    Leading and trailing slashes in path are removed from the final URL.
-    """
-    # See test_get_repo_file_url for precise specifications
-    path = "/" + path.lstrip("/")
-    part = "tree" if path.endswith("/") else "blob"
-    return f"https://github.com/{repository}/{part}/{branch}{path}".rstrip("/")
-
-
-def get_html_report_url(repository: str, branch: str) -> str:
-    readme_url = get_repo_file_url(
-        repository=repository, branch=branch, path="/htmlcov/index.html"
-    )
-    return f"https://htmlpreview.github.io/?{readme_url}"
+def get_readme_url(repository: str, branch: str) -> str:
+    return f"https://github.com/{repository}/tree/{branch}"
 
 
 def fix_ownership_issues(git: subprocess.Git):
diff --git a/coverage_comment/template.py b/coverage_comment/template.py
index 79004e0..5001902 100644
--- a/coverage_comment/template.py
+++ b/coverage_comment/template.py
@@ -39,7 +39,7 @@ class TemplateError(Exception):
     pass
 
 
-def get_comment_markdown(
+def get_markdown_comment(
     coverage: coverage_module.Coverage,
     diff_coverage: coverage_module.DiffCoverage,
     previous_coverage_rate: decimal.Decimal | None,
@@ -66,52 +66,8 @@ def get_comment_markdown(
     return comment
 
 
-def get_readme_markdown(
-    is_public: bool,
-    readme_url: str,
-    markdown_report: str,
-    direct_image_url: str,
-    html_report_url: str | None,
-    dynamic_image_url: str | None,
-    endpoint_image_url: str | None,
-):
-    env = SandboxedEnvironment()
-    template = jinja2.Template(read_template_file("readme.md.j2"))
-    return env.get_template(template).render(
-        is_public=is_public,
-        readme_url=readme_url,
-        markdown_report=markdown_report,
-        direct_image_url=direct_image_url,
-        html_report_url=html_report_url,
-        dynamic_image_url=dynamic_image_url,
-        endpoint_image_url=endpoint_image_url,
-    )
-
-
-def get_log_message(
-    is_public: bool,
-    readme_url: str,
-    direct_image_url: str,
-    html_report_url: str | None,
-    dynamic_image_url: str | None,
-    endpoint_image_url: str | None,
-):
-    env = SandboxedEnvironment()
-    template = jinja2.Template(read_template_file("log.txt.j2"))
-    return env.get_template(template).render(
-        is_public=is_public,
-        html_report_url=html_report_url,
-        direct_image_url=direct_image_url,
-        endpoint_image_url=endpoint_image_url,
-        dynamic_image_url=dynamic_image_url,
-        readme_url=readme_url,
-    )
-
-
-def read_template_file(template: str) -> str:
-    return (
-        resources.files("coverage_comment") / "template_files" / template
-    ).read_text()
+def read_template_file() -> str:
+    return resources.read_text("coverage_comment", "default.md.j2")
 
 
 def pct(val: decimal.Decimal | float) -> str:
diff --git a/coverage_comment/template_files/log.txt.j2 b/coverage_comment/template_files/log.txt.j2
deleted file mode 100644
index 0b69f09..0000000
--- a/coverage_comment/template_files/log.txt.j2
+++ /dev/null
@@ -1,20 +0,0 @@
-{% if is_public -%}
-You can browse the full coverage report at:
-    {{ html_report_url }}
-
-{% endif -%}
-You can use the following URLs to display your badge:
-
-- Badge SVG available at:
-    {{ direct_image_url }}
-
-{% if is_public -%}
-- Badge from shields endpoint is easier to customize but doesn't work with private repo:
-    {{ endpoint_image_url }}
-
-- Badge from shields dynamic url (less useful but you never know):
-    {{ dynamic_image_url }}
-
-{% endif -%}
-See more details and ready-to-copy-paste-markdown at:
-    {{ readme_url }}
diff --git a/coverage_comment/template_files/readme.md.j2 b/coverage_comment/template_files/readme.md.j2
deleted file mode 100644
index 8f85075..0000000
--- a/coverage_comment/template_files/readme.md.j2
+++ /dev/null
@@ -1,39 +0,0 @@
-# Repository Coverage
-
-{% if is_public -%}
-[Full report]({{ html_report_url }})
-{%- endif %}
-
-{{ markdown_report }}
-
-## Setup coverage badge
-
-Below are examples of the badges you can use in your main branch `README` file.
-
-### Direct image
-
-[![Coverage badge]({{ direct_image_url }})]({{ html_report_url if is_public else readme_url }})
-
-This is the one to use if your repository is private or if you don't want to customize anything.
-
-{% if is_public -%}
-### [Shields.io](https://shields.io) Json Endpoint
-
-[![Coverage badge]({{ endpoint_image_url }})]({{html_report_url}})
-
-Using this one will allow you to [customize](https://shields.io/endpoint) the look of your badge.
-It won't work with private repositories. It won't be refreshed more than once per five minutes.
-
-### [Shields.io](https://shields.io) Dynamic Badge
-
-[![Coverage badge]({{ dynamic_image_url }})]({{ html_report_url }})
-
-This one will always be the same color. It won't work for private repos. I'm not even sure why we included it.
-{%- endif %}
-
-## What is that?
-
-This branch is part of the
-[python-coverage-comment-action](https://github.com/marketplace/actions/python-coverage-comment)
-GitHub Action. All the files in this branch are automatically generated and may be
-overwritten at any moment.


Test patch:
diff --git a/tests/end_to_end/test_all.py b/tests/end_to_end/test_all.py
index b69461a..e92de73 100644
--- a/tests/end_to_end/test_all.py
+++ b/tests/end_to_end/test_all.py
@@ -50,30 +50,27 @@ def test_public_repo(
     # The easiest way to check the links is to assume there will be no other
     # line with a link prefixed by 4 spaces. If at some point there is, we'll
     # change the test.
-    links = {line.strip().split()[-1] for line in log_lines if "    https://" in line}
-    # - html report
-    # - badge 1, 2 and 3
-    # - coverage branch readme url
-    assert len(links) == 5
+    links = [line.strip().split()[-1] for line in log_lines if "    https://" in line]
+    assert len(links) == 3
 
     client = httpx.Client()
 
-    # Check that all 5 links are valid and lead to a 200
+    # Check that all 3 links are valid and lead to a 200
     # It's made this way to avoid hardcoding links in the test, because I assume
     # they'll be evolving.
-    number_of_svgs = 0
     for link in links:
         response = client.get(link)
         response.raise_for_status()
-        number_of_svgs += int(response.text.startswith("<svg"))
-
-    assert number_of_svgs == 3
+        assert response.text.startswith("<svg")
 
     # Check that logs point to the branch that has the readme file.
     data_branch_url = (
         f"https://github.com/{repo_full_name}/tree/python-coverage-comment-action-data"
     )
-    assert data_branch_url in links
+    assert data_branch_url in logs
+
+    # Also, at this point, the branch should really exist.
+    client.get(data_branch_url).raise_for_status()
 
     # Time to check the Readme contents
     raw_url_prefix = (
@@ -85,7 +82,7 @@ def test_public_repo(
     response.raise_for_status()
     # And all previously found links should be present
     readme = response.text
-    for link in links - {data_branch_url}:
+    for link in links:
         assert link in readme
 
     # And while we're at it, there are 2 other files we want to check in this
diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py
index 99df984..c43fddc 100644
--- a/tests/integration/test_main.py
+++ b/tests/integration/test_main.py
@@ -323,8 +323,6 @@ def test_action__push__default_branch(
     git.register("git add endpoint.json")()
     git.register("git add data.json")()
     git.register("git add badge.svg")()
-    git.register("git add htmlcov")()
-    git.register("git add README.md")()
     git.register("git diff --staged --exit-code")(exit_code=1)
     git.register("git commit --message Update badge")()
     git.register("git push origin python-coverage-comment-action-data")()
@@ -339,70 +337,21 @@ def test_action__push__default_branch(
     assert result == 0
 
     assert not get_logs("INFO", "Skipping badge")
-    assert get_logs("INFO", "Saving coverage files")
+    assert get_logs("INFO", "Saving coverage files & badge into the repository")
 
     log = get_logs("INFO", "Badge SVG available at")[0]
-    expected = """You can browse the full coverage report at:
-    https://htmlpreview.github.io/?https://github.com/py-cov-action/foobar/blob/python-coverage-comment-action-data/htmlcov/index.html
-
-You can use the following URLs to display your badge:
+    expected = """You can use the following URLs to display your badge:
 
-- Badge SVG available at:
+Badge SVG available at:
     https://raw.githubusercontent.com/py-cov-action/foobar/python-coverage-comment-action-data/badge.svg
 
-- Badge from shields endpoint is easier to customize but doesn't work with private repo:
+Badge from shields endpoint is easier to customize but doesn't work with private repo:
     https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/py-cov-action/foobar/python-coverage-comment-action-data/endpoint.json
 
-- Badge from shields dynamic url (less useful but you never know):
+Badge from shields dynamic url (less useful but you never know):
     https://img.shields.io/badge/dynamic/json?color=brightgreen&label=coverage&query=%24.message&url=https%3A%2F%2Fraw.githubusercontent.com%2Fpy-cov-action%2Ffoobar%2Fpython-coverage-comment-action-data%2Fendpoint.json
 
-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
-
-
-def test_action__push__default_branch__private(
-    push_config, session, in_integration_env, get_logs, git
-):
-    session.register("GET", "/repos/py-cov-action/foobar")(
-        json={"default_branch": "main", "visibility": "private"}
-    )
-    session.register(
-        "GET",
-        "https://img.shields.io/static/v1?label=Coverage&message=85%25&color=orange",
-    )(text="<this is a svg badge>")
-
-    git.register("git branch --show-current")(stdout="foo")
-    git.register("git fetch")()
-    git.register("git checkout python-coverage-comment-action-data")()
-    git.register("git add endpoint.json")()
-    git.register("git add data.json")()
-    git.register("git add badge.svg")()
-    git.register("git add README.md")()
-    git.register("git diff --staged --exit-code")(exit_code=1)
-    git.register("git commit --message Update badge")()
-    git.register("git push origin python-coverage-comment-action-data")()
-    git.register("git checkout foo")()
-
-    result = main.action(
-        config=push_config(),
-        github_session=session,
-        http_session=session,
-        git=git,
-    )
-    assert result == 0
-
-    assert not get_logs("INFO", "Skipping badge")
-    assert get_logs("INFO", "Saving coverage files")
-
-    log = get_logs("INFO", "Badge SVG available at")[0]
-    expected = """You can use the following URLs to display your badge:
-
-- Badge SVG available at:
-    https://github.com/py-cov-action/foobar/raw/python-coverage-comment-action-data/badge.svg
-
-See more details and ready-to-copy-paste-markdown at:
-    https://github.com/py-cov-action/foobar/tree/python-coverage-comment-action-data"""
+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
 
 
diff --git a/tests/unit/test_communication.py b/tests/unit/test_communication.py
index 7fdb2b0..ec8243b 100644
--- a/tests/unit/test_communication.py
+++ b/tests/unit/test_communication.py
@@ -1,69 +1,36 @@
-from coverage_comment import communication
-
-
-def test_get_readme_and_log__public():
-    readme_file, log = communication.get_readme_and_log(
-        is_public=True,
-        image_urls={
-            "direct": "https://a",
-            "endpoint": "https://b",
-            "dynamic": "https://c",
-        },
-        readme_url="https://readme",
-        html_report_url="https://html_report",
-        markdown_report="**Hello report!**",
-    )
-
-    readme = readme_file.contents
+import pytest
 
-    assert str(readme_file.path) == "README.md"
-
-    assert "# Repository Coverage" in readme
-
-    assert "[![Coverage badge](https://a)](https://html_report)" in readme
-
-    assert "[![Coverage badge](https://b)](https://html_report)" in readme
-
-    assert "[![Coverage badge](https://c)](https://html_report)" in readme
-
-    assert "https://a" in log
-
-    assert "https://readme" in log
-
-    assert "https://b" in log
-
-    assert "https://c" in log
+from coverage_comment import communication
 
 
-def test_get_readme_and_log__private():
+@pytest.mark.parametrize("is_public", [True, False])
+def test_get_readme_and_log(is_public):
     readme_file, log = communication.get_readme_and_log(
-        is_public=False,
         image_urls={
             "direct": "https://a",
             "endpoint": "https://b",
             "dynamic": "https://c",
         },
         readme_url="https://readme",
-        html_report_url="https://html_report",
-        markdown_report="**Hello report!**",
+        is_public=is_public,
     )
 
     readme = readme_file.contents
 
     assert str(readme_file.path) == "README.md"
 
-    assert "# Repository Coverage" in readme
+    assert "# Coverage data" in readme
 
     assert "[![Coverage badge](https://a)](https://readme)" in readme
 
-    assert "https://b" not in readme
+    assert ("[![Coverage badge](https://b)](https://readme)" in readme) is (is_public)
 
-    assert "https://c" not in readme
+    assert ("[![Coverage badge](https://c)](https://readme)" in readme) is (is_public)
 
     assert "https://a" in log
 
     assert "https://readme" in log
 
-    assert "https://b" not in log
+    assert ("https://b" in log) is (is_public)
 
-    assert "https://c" not in log
+    assert ("https://c" in log) is (is_public)
diff --git a/tests/unit/test_coverage.py b/tests/unit/test_coverage.py
index c1373dc..5c6e1f7 100644
--- a/tests/unit/test_coverage.py
+++ b/tests/unit/test_coverage.py
@@ -68,27 +68,3 @@ def test_get_coverage_info__error_no_source(mocker, get_logs):
         coverage.get_coverage_info(merge=False)
 
     assert get_logs("ERROR", "Cannot read")
-
-
-def test_generate_coverage_html_files(mocker):
-    run = mocker.patch(
-        "coverage_comment.subprocess.run",
-    )
-
-    coverage.generate_coverage_html_files()
-
-    assert run.call_args_list == [
-        mocker.call("coverage", "html", "--skip-empty"),
-    ]
-
-
-def test_generate_coverage_markdown(mocker):
-    run = mocker.patch("coverage_comment.subprocess.run", return_value="foo")
-
-    result = coverage.generate_coverage_markdown()
-
-    assert run.call_args_list == [
-        mocker.call("coverage", "report", "--format=markdown", "--show-missing"),
-    ]
-
-    assert result == "foo"
diff --git a/tests/unit/test_files.py b/tests/unit/test_files.py
index 319072a..152314d 100644
--- a/tests/unit/test_files.py
+++ b/tests/unit/test_files.py
@@ -52,18 +52,3 @@ def test_get_urls():
         "dynamic": "https://img.shields.io/badge/dynamic/json?color=brightgreen&label=coverage&query=%24.message&url=https%3A%2F%2Fendpoint.json",
         "endpoint": "https://img.shields.io/endpoint?url=https://endpoint.json",
     }
-
-
-def test_get_coverage_html_files(mocker, in_tmp_path):
-    gen = mocker.patch("coverage_comment.coverage.generate_coverage_html_files")
-    cov = in_tmp_path / "htmlcov"
-    cov.mkdir()
-    gitignore = cov / ".gitignore"
-    gitignore.touch()
-
-    assert files.get_coverage_html_files() == files.FileWithPath(
-        path=pathlib.Path("htmlcov"), contents=None
-    )
-
-    assert gen.called is True
-    assert not gitignore.exists()
diff --git a/tests/unit/test_storage.py b/tests/unit/test_storage.py
index e79003b..83eb0f5 100644
--- a/tests/unit/test_storage.py
+++ b/tests/unit/test_storage.py
@@ -74,7 +74,6 @@ def test_upload_files(git, in_tmp_path, branch_exists, has_diff):
     files_to_save = [
         files.FileWithPath(path=pathlib.Path("a.txt"), contents="a"),
         files.FileWithPath(path=pathlib.Path("b.txt"), contents="b"),
-        files.FileWithPath(path=pathlib.Path("c.txt"), contents=None),
     ]
 
     # on_coverage_branch
@@ -104,8 +103,6 @@ def test_upload_files(git, in_tmp_path, branch_exists, has_diff):
     # upload_files
     git.register(f"git add {files_to_save[0].path}")()
     git.register(f"git add {files_to_save[1].path}")()
-    git.register(f"git add {files_to_save[2].path}")()
-    git.register("git add readme.txt")()
     git.register("git diff --staged --exit-code")(exit_code=1 if has_diff else 0)
 
     if has_diff:
@@ -134,7 +131,6 @@ def test_upload_files(git, in_tmp_path, branch_exists, has_diff):
 
     assert files_to_save[0].path.read_text() == files_to_save[0].contents
     assert files_to_save[1].path.read_text() == files_to_save[1].contents
-    assert not files_to_save[2].path.exists()
 
 
 def test_get_datafile_contents__not_found(gh, session):
@@ -171,8 +167,8 @@ def test_get_datafile_contents(gh, session):
         (True, "https://raw.githubusercontent.com/foo/bar/baz/qux"),
     ],
 )
-def test_get_raw_file_url(is_public, expected):
-    result = storage.get_raw_file_url(
+def test_get_file_url(is_public, expected):
+    result = storage.get_file_url(
         repository="foo/bar",
         branch="baz",
         path=pathlib.Path("qux"),
@@ -181,30 +177,7 @@ def test_get_raw_file_url(is_public, expected):
     assert result == expected
 
 
-@pytest.mark.parametrize(
-    "path, expected",
-    [
-        ("", "https://github.com/foo/bar/tree/baz"),
-        ("/", "https://github.com/foo/bar/tree/baz"),
-        ("qux", "https://github.com/foo/bar/blob/baz/qux"),  # blob
-        ("qux/", "https://github.com/foo/bar/tree/baz/qux"),
-        ("/qux", "https://github.com/foo/bar/blob/baz/qux"),  # blob
-        ("/qux/", "https://github.com/foo/bar/tree/baz/qux"),
-    ],
-)
-def test_get_repo_file_url(path, expected):
-    result = storage.get_repo_file_url(repository="foo/bar", branch="baz", path=path)
-
-    assert result == expected
-
-
-def test_get_repo_file_url__no_path():
-    result = storage.get_repo_file_url(repository="foo/bar", branch="baz")
+def test_get_readme_url():
+    result = storage.get_readme_url(repository="foo/bar", branch="baz")
 
     assert result == "https://github.com/foo/bar/tree/baz"
-
-
-def test_get_html_report_url():
-    result = storage.get_html_report_url(repository="foo/bar", branch="baz")
-    expected = "https://htmlpreview.github.io/?https://github.com/foo/bar/blob/baz/htmlcov/index.html"
-    assert result == expected
diff --git a/tests/unit/test_template.py b/tests/unit/test_template.py
index 9dfed3a..fde6466 100644
--- a/tests/unit/test_template.py
+++ b/tests/unit/test_template.py
@@ -6,9 +6,9 @@ import pytest
 from coverage_comment import coverage, template
 
 
-def test_get_comment_markdown(coverage_obj, diff_coverage_obj):
+def test_get_markdown_comment(coverage_obj, diff_coverage_obj):
     result = (
-        template.get_comment_markdown(
+        template.get_markdown_comment(
             coverage=coverage_obj,
             diff_coverage=diff_coverage_obj,
             previous_coverage_rate=decimal.Decimal("0.92"),
@@ -39,11 +39,11 @@ def test_get_comment_markdown(coverage_obj, diff_coverage_obj):
 
 
 def test_template(coverage_obj, diff_coverage_obj):
-    result = template.get_comment_markdown(
+    result = template.get_markdown_comment(
         coverage=coverage_obj,
         diff_coverage=diff_coverage_obj,
         previous_coverage_rate=decimal.Decimal("0.92"),
-        base_template=template.read_template_file("comment.md.j2"),
+        base_template=template.read_template_file(),
         custom_template="""{% extends "base" %}
         {% block emoji_coverage_down %}:sob:{% endblock emoji_coverage_down %}
         """,
@@ -142,11 +142,11 @@ def test_template_full():
         },
     )
 
-    result = template.get_comment_markdown(
+    result = template.get_markdown_comment(
         coverage=cov,
         diff_coverage=diff_cov,
         previous_coverage_rate=decimal.Decimal("1.0"),
-        base_template=template.read_template_file("comment.md.j2"),
+        base_template=template.read_template_file(),
     )
     expected = """## Coverage report
 The coverage rate went from `100%` to `100%` :arrow_right:
@@ -178,11 +178,11 @@ def test_template__no_new_lines_with_coverage(coverage_obj):
         files={},
     )
 
-    result = template.get_comment_markdown(
+    result = template.get_markdown_comment(
         coverage=coverage_obj,
         diff_coverage=diff_cov,
         previous_coverage_rate=decimal.Decimal("1.0"),
-        base_template=template.read_template_file("comment.md.j2"),
+        base_template=template.read_template_file(),
     )
     expected = """## Coverage report
 The coverage rate went from `100%` to `75%` :arrow_down:
@@ -196,11 +196,11 @@ _None of the new lines are part of the tested code. Therefore, there is no cover
 
 
 def test_template__no_branch_no_previous(coverage_obj_no_branch, diff_coverage_obj):
-    result = template.get_comment_markdown(
+    result = template.get_markdown_comment(
         coverage=coverage_obj_no_branch,
         diff_coverage=diff_coverage_obj,
         previous_coverage_rate=None,
-        base_template=template.read_template_file("comment.md.j2"),
+        base_template=template.read_template_file(),
     )
     expected = """## Coverage report
 > **Note**
@@ -223,29 +223,29 @@ Missing lines: `7`, `9`
 
 
 def test_read_template_file():
-    assert template.read_template_file("comment.md.j2").startswith(
+    assert template.read_template_file().startswith(
         "{% block title %}## Coverage report{% endblock title %}"
     )
 
 
 def test_template__no_marker(coverage_obj, diff_coverage_obj):
     with pytest.raises(template.MissingMarker):
-        template.get_comment_markdown(
+        template.get_markdown_comment(
             coverage=coverage_obj,
             diff_coverage=diff_coverage_obj,
             previous_coverage_rate=decimal.Decimal("0.92"),
-            base_template=template.read_template_file("comment.md.j2"),
+            base_template=template.read_template_file(),
             custom_template="""foo bar""",
         )
 
 
 def test_template__broken_template(coverage_obj, diff_coverage_obj):
     with pytest.raises(template.TemplateError):
-        template.get_comment_markdown(
+        template.get_markdown_comment(
             coverage=coverage_obj,
             diff_coverage=diff_coverage_obj,
             previous_coverage_rate=decimal.Decimal("0.92"),
-            base_template=template.read_template_file("comment.md.j2"),
+            base_template=template.read_template_file(),
             custom_template="""{% extends "foo" %}""",
         )