-
Notifications
You must be signed in to change notification settings - Fork 40
Adds additional support for Github enterprise usecases #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Adds additional support for Github enterprise usecases #548
Conversation
…st merge to the default branch. This is functionally equivalent to the currently supported pattern of pushing to the default branch.
Adds support for figuring out a github host from the `GITHUB_BASE_URL` config and using this value in generated coverage artifacts rather than hardcoding them to "github.com"
for more information, see https://pre-commit.ci
Admin commands cheatsheet:
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
for more information, see https://pre-commit.ci
…iel-anya/python-coverage-comment-action into additional-support-for-gh-enterprise
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a stellar contribution 🤩
I'm sorry it took so long to find the time to review it.
I think what it mainly needs is documentation in README. In particular:
- That you can use the pull_request merged event
- How to setup GH pages
- Maybe add some details on how it works for GHE ?
coverage_comment/main.py
Outdated
with open(event_path, "r") as event_file: | ||
event_payload = json.load(event_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use Pathlib
everywhere else in the project, and event_path is already a path
with open(event_path, "r") as event_file: | |
event_payload = json.load(event_file) | |
event_payload = json.loads(event_path.read_text()) |
coverage_comment/activity.py
Outdated
) -> str: | ||
"""Find the activity to perform based on the event type and payload.""" | ||
if event_name == "workflow_run": | ||
return "post_comment" | ||
|
||
if (event_name == "push" and is_default_branch) or event_name == "schedule": | ||
if (event_name == "push" and is_default_branch) or (event_name == "pull_request" and event_action == "merged" and is_default_branch) or event_name == "schedule": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should be a mention of this in the README too?
@@ -47,7 +47,7 @@ function create-repo(){ | |||
repo_dirname=$(basename ${GITHUB_REPOSITORY}) | |||
mv "${repo_dirname}/"{*,.*} . | |||
rmdir "${repo_dirname}" | |||
git pull --ff-only origin master | |||
git pull --ff-only origin main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch !
# Special case for GitHub.com API | ||
if netloc == "api.github.com": | ||
host_domain = "github.com" | ||
# Special case for GitHub.com with port (less common but good practice) | ||
elif netloc.startswith("api.github.com:"): | ||
# Remove 'api.' prefix but keep the port | ||
host_domain = netloc.replace("api.", "", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Special case for GitHub.com API | |
if netloc == "api.github.com": | |
host_domain = "github.com" | |
# Special case for GitHub.com with port (less common but good practice) | |
elif netloc.startswith("api.github.com:"): | |
# Remove 'api.' prefix but keep the port | |
host_domain = netloc.replace("api.", "", 1) | |
# Special case for GitHub.com API (including possible port) | |
if re.match(r"api\.github\.com(:|$)", netloc): | |
# Remove 'api.' prefix but keep the port | |
host_domain = netloc.removeprefix("api.") |
Oh, and there are 4 lines missing coverage 😅 |
5764cba: Adds support for figuring out a Github host from the
GITHUB_BASE_URL
config, and using this value in generated coverage artifacts. The usecase here is that, when this action is used in the enterprise environment, coverage artifacts like html files and README docs point togithub.com/...
which is not what we'd want.07a88e1: Adds support for saving coverage artifacts on
PR merged to default branch
events which is functionally equivalent to the currently supported path of saving coverage artifacts oncommit pushed to default branch
events.78a7324: Adds support for generating Github Pages based coverage report links.
Tested all changes in a Github enterprise environment and they've been working fine for a while now.