From ba31f226d9c5acaea8e08c02192e05894c92271e Mon Sep 17 00:00:00 2001 From: Daniel Anya Date: Wed, 15 Jan 2025 16:35:28 -0500 Subject: [PATCH 1/6] Adds `GITHUB_BASE_URL` input --- action.yml | 7 +++++++ coverage_comment/main.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 362dfebf..aa1f74a5 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: + GITHUB_BASE_URL: + description: > + The base URL for the GitHub API, typically used to specify custom endpoints + for GitHub Enterprise Server (e.g., `https://github.mycompany.com/api/v3`). + Defaults to `https://api.github.com` for GitHub.com. + default: "https://api.github.com" + required: false GITHUB_TOKEN: description: > A GitHub token to write comments and write the badge & coverage data diff --git a/coverage_comment/main.py b/coverage_comment/main.py index 71c5bedc..8da1c792 100644 --- a/coverage_comment/main.py +++ b/coverage_comment/main.py @@ -34,7 +34,7 @@ def main(): config = settings.Config.from_environ(environ=os.environ) github_session = httpx.Client( - base_url="https://api.github.com", + base_url=config.GITHUB_BASE_URL, follow_redirects=True, headers={"Authorization": f"token {config.GITHUB_TOKEN}"}, ) From c0d7e4500cde2a7cfb493ccb7158c205de233bb5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:01:17 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index aa1f74a5..9a6c2c70 100644 --- a/action.yml +++ b/action.yml @@ -8,8 +8,8 @@ description: > inputs: GITHUB_BASE_URL: description: > - The base URL for the GitHub API, typically used to specify custom endpoints - for GitHub Enterprise Server (e.g., `https://github.mycompany.com/api/v3`). + The base URL for the GitHub API, typically used to specify custom endpoints + for GitHub Enterprise Server (e.g., `https://github.mycompany.com/api/v3`). Defaults to `https://api.github.com` for GitHub.com. default: "https://api.github.com" required: false From 2b3c828c51eae12eeddb1f41cdc4c584e76adcd9 Mon Sep 17 00:00:00 2001 From: Daniel Anya Date: Wed, 29 Jan 2025 14:10:58 -0500 Subject: [PATCH 3/6] Updates documentation + config to include GHE support --- .gitignore | 1 + README.md | 6 ++++++ coverage_comment/settings.py | 1 + 3 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 95d0cfed..5e8ed586 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dev-env-vars .coverage* __pycache__ +.idea/ diff --git a/README.md b/README.md index 028929fc..e034b868 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,8 @@ jobs: id: coverage_comment uses: py-cov-action/python-coverage-comment-action@v3 with: + GITHUB_BASE_URL: https://api.github.com + GITHUB_TOKEN: ${{ github.token }} # Only necessary in the "workflow_run" workflow. @@ -594,6 +596,10 @@ source = This action is supposedly compatible with private repository. Just make sure to use the svg badge directly, and not the `shields.io` URL. +## Github Enterprise(GHE) Support + +This action should be compatible with GitHub Enterprise. Just make sure to set the `GITHUB_BASE_URL` input to your GHE URL. + ## Upgrading from v2 to v3 When upgrading, we change the location and format where the coverage diff --git a/coverage_comment/settings.py b/coverage_comment/settings.py index 5d4360b7..12473c7d 100644 --- a/coverage_comment/settings.py +++ b/coverage_comment/settings.py @@ -37,6 +37,7 @@ class Config: # A branch name, not a fully-formed ref. For example, `main`. GITHUB_BASE_REF: str + GITHUB_BASE_URL: str = "https://api.github.com" GITHUB_TOKEN: str = dataclasses.field(repr=False) GITHUB_REPOSITORY: str # > The ref given is fully-formed, meaning that for branches the format is From 5ab0503749682f4f8940e22739db98caedc6207d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 19:11:18 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e034b868..612bfc1e 100644 --- a/README.md +++ b/README.md @@ -312,7 +312,7 @@ jobs: uses: py-cov-action/python-coverage-comment-action@v3 with: GITHUB_BASE_URL: https://api.github.com - + GITHUB_TOKEN: ${{ github.token }} # Only necessary in the "workflow_run" workflow. From c3692ce2558ed59f07658e2eef1c873cd181c980 Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Mon, 17 Feb 2025 22:38:23 +0100 Subject: [PATCH 5/6] Apply suggestions from code review --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 612bfc1e..0d5088d7 100644 --- a/README.md +++ b/README.md @@ -311,9 +311,10 @@ jobs: id: coverage_comment uses: py-cov-action/python-coverage-comment-action@v3 with: - GITHUB_BASE_URL: https://api.github.com - GITHUB_TOKEN: ${{ github.token }} + + # Change this in case you use GitHub Entreprise with a different API endpoint + GITHUB_BASE_URL: https://api.github.com # Only necessary in the "workflow_run" workflow. GITHUB_PR_RUN_ID: ${{ inputs.GITHUB_PR_RUN_ID }} @@ -596,7 +597,7 @@ source = This action is supposedly compatible with private repository. Just make sure to use the svg badge directly, and not the `shields.io` URL. -## Github Enterprise(GHE) Support +## Github Enterprise (GHE) Support This action should be compatible with GitHub Enterprise. Just make sure to set the `GITHUB_BASE_URL` input to your GHE URL. From 60d5d011d609ec30fd974cbe4c21f35e0e651d08 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 21:38:32 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d5088d7..2fcbfc43 100644 --- a/README.md +++ b/README.md @@ -312,7 +312,7 @@ jobs: uses: py-cov-action/python-coverage-comment-action@v3 with: GITHUB_TOKEN: ${{ github.token }} - + # Change this in case you use GitHub Entreprise with a different API endpoint GITHUB_BASE_URL: https://api.github.com