From b1edcf996436c1f0b9c38f43ba885657fcf95019 Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Mon, 22 Jun 2026 01:04:56 +0200 Subject: [PATCH 1/4] Add activity in action --- action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/action.yml b/action.yml index 18220909..9dd37a72 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,13 @@ description: > Publish diff coverage report as PR comment, and create a coverage badge to display on the readme. inputs: + ACTIVITY: + description: > + Use this setting to override the auto-selection of the proper activity + ("process_pr", "post_comment", "save_coverage_data_files"). + By default, a heuristic based on the event that triggers the worflow will + auto-select the proper activity + required: false GITHUB_BASE_URL: description: > The base URL for the GitHub API, typically used to specify custom endpoints @@ -168,6 +175,7 @@ runs: using: docker image: Dockerfile env: + ACTIVITY: ${{ inputs.ACTIVITY }} GITHUB_BASE_URL: ${{ inputs.GITHUB_BASE_URL }} GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} GITHUB_PR_RUN_ID: ${{ inputs.GITHUB_PR_RUN_ID }} From edcd720ab98da8240c5b516d00b0efbceb688bf5 Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Mon, 22 Jun 2026 01:05:09 +0200 Subject: [PATCH 2/4] Add 2 missing params --- action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yml b/action.yml index 9dd37a72..592bad13 100644 --- a/action.yml +++ b/action.yml @@ -191,3 +191,5 @@ runs: ANNOTATE_MISSING_LINES: ${{ inputs.ANNOTATE_MISSING_LINES }} ANNOTATION_TYPE: ${{ inputs.ANNOTATION_TYPE }} VERBOSE: ${{ inputs.VERBOSE }} + MAX_FILES_IN_COMMENT: ${{ inputs.MAX_FILES_IN_COMMENT }} + USE_GH_PAGES_HTML_URL: ${{ inputs.USE_GH_PAGES_HTML_URL }} From b95bc7923d8098365f99a71fa7f1d7d55bf7441a Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Mon, 22 Jun 2026 01:14:30 +0200 Subject: [PATCH 3/4] Handle no-activity --- coverage_comment/settings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coverage_comment/settings.py b/coverage_comment/settings.py index 4f7aa9ae..4037e350 100644 --- a/coverage_comment/settings.py +++ b/coverage_comment/settings.py @@ -134,7 +134,9 @@ def clean_github_event_path(cls, value: str) -> pathlib.Path: return pathlib.Path(value) @classmethod - def clean_activity(cls, activity: str) -> activities.Activity: + def clean_activity(cls, activity: str) -> activities.Activity | None: + if not activity: + return None return activities.Activity(activity) @property From 9be84c44d8a3b156f60eee3b6c9af0b071fecf79 Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Mon, 22 Jun 2026 22:27:30 +0200 Subject: [PATCH 4/4] Don't pass empty values, use defaults --- coverage_comment/settings.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/coverage_comment/settings.py b/coverage_comment/settings.py index 4037e350..1bd695bc 100644 --- a/coverage_comment/settings.py +++ b/coverage_comment/settings.py @@ -39,7 +39,7 @@ class Config: """This object defines the environment variables""" # A branch name, not a fully-formed ref. For example, `main`. - GITHUB_BASE_REF: str + GITHUB_BASE_REF: str = "" GITHUB_BASE_URL: str = "https://api.github.com" GITHUB_TOKEN: str = dataclasses.field(repr=False) GITHUB_REPOSITORY: str @@ -51,7 +51,7 @@ class Config: GITHUB_REF: str GITHUB_EVENT_NAME: str GITHUB_EVENT_PATH: pathlib.Path | None = None - GITHUB_PR_RUN_ID: int | None + GITHUB_PR_RUN_ID: int | None = None GITHUB_STEP_SUMMARY: pathlib.Path COMMENT_TEMPLATE: str | None = None COVERAGE_DATA_BRANCH: str = "python-coverage-comment-action-data" @@ -83,7 +83,7 @@ def clean_minimum_orange(cls, value: str) -> decimal.Decimal: @classmethod def clean_github_pr_run_id(cls, value: str) -> int | None: - return int(value) if value else None + return int(value) @classmethod def clean_github_step_summary(cls, value: str) -> pathlib.Path: @@ -133,10 +133,16 @@ def clean_github_output(cls, value: str) -> pathlib.Path: def clean_github_event_path(cls, value: str) -> pathlib.Path: return pathlib.Path(value) + @classmethod + def clean_max_files_in_comment(cls, value: str) -> int: + return int(value) + + @classmethod + def clean_use_gh_pages_html_url(cls, value: str) -> bool: + return str_to_bool(value) + @classmethod def clean_activity(cls, activity: str) -> activities.Activity | None: - if not activity: - return None return activities.Activity(activity) @property @@ -193,6 +199,7 @@ def from_environ(cls, environ: MutableMapping[str, Any]) -> Config: config: dict[str, Any] = { k: v for k, v in environ.items() if k in possible_variables } + config = {k: v for k, v in config.items() if v != ""} for key, value in list(config.items()): if func := getattr(cls, f"clean_{key.lower()}", None): try: