Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
17 changes: 13 additions & 4 deletions coverage_comment/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"""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
Expand All @@ -51,7 +51,7 @@
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"
Expand Down Expand Up @@ -83,7 +83,7 @@

@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:
Expand Down Expand Up @@ -134,7 +134,15 @@
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)

Check warning on line 138 in coverage_comment/settings.py

View workflow job for this annotation

GitHub Actions / Run tests & display coverage

Missing coverage

Missing coverage on line 138

@classmethod
def clean_use_gh_pages_html_url(cls, value: str) -> bool:
return str_to_bool(value)

Check warning on line 142 in coverage_comment/settings.py

View workflow job for this annotation

GitHub Actions / Run tests & display coverage

Missing coverage

Missing coverage on line 142

@classmethod
def clean_activity(cls, activity: str) -> activities.Activity | None:
return activities.Activity(activity)

@property
Expand Down Expand Up @@ -191,6 +199,7 @@
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:
Expand Down
Loading