diff --git a/action.yml b/action.yml index 18220909..592bad13 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 }} @@ -183,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 }} diff --git a/coverage_comment/settings.py b/coverage_comment/settings.py index 4f7aa9ae..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: @@ -134,7 +134,15 @@ 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_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: return activities.Activity(activity) @property @@ -191,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: