Add GitHub Enterprise support#3720
Open
arhowe00 wants to merge 6 commits into
Open
Conversation
Enable CDash to post check runs and commit statuses to ghe installations in addition to github.com. Changes: - Add GITHUB_ENTERPRISE_URL config option (env var) - Pass enterprise URL to GitHubClient constructor with apiVersion=null (so it defaults to 'v3') so the PathPrepend plugin builds correct /api/v3/ paths for ghe - Add isGitHubUrl() helpers in GitHub.php and RepositoryUtils.php to match repository URLs against both github.com and the configured GHE host - Convert get_github_api_url() to construct /api/v3/repos/ paths for GHE repositories - Make DoneHandler always create/update the check when a revision exists, rather than requiring the pendingSubmissions recheck flag
williamjallen
requested changes
Jun 2, 2026
Comment on lines
-87
to
+91
| $repositoryInterface = self::getRepositoryInterface($project); | ||
| try { | ||
| $repositoryInterface = self::getRepositoryInterface($project); | ||
| } catch (Exception $e) { | ||
| return; | ||
| } |
Collaborator
There was a problem hiding this comment.
Why is this necessary? This will destroy all exceptions within getRepositoryInterface(), preventing them from making it to the logs.
Comment on lines
-66
to
+68
| // Should we re-run any checks that were previously marked | ||
| // as pending? | ||
| if ($pendingSubmissionsModel !== null && $pendingSubmissionsModel->recheck) { | ||
| $revision = \App\Models\Build::findOrFail((int) $this->Build->Id)->updateStep->revision ?? ''; | ||
| // Create or update the GitHub check for this commit. | ||
| $revision = \App\Models\Build::findOrFail((int) $this->Build->Id)->updateStep->revision ?? ''; | ||
| if ($revision !== '') { |
Collaborator
There was a problem hiding this comment.
What's the thought process here?
Comment on lines
+17
to
+28
| private static function isGitHubUrl(string $url): bool | ||
| { | ||
| if (str_contains($url, 'github.com')) { | ||
| return true; | ||
| } | ||
| $enterpriseUrl = config('cdash.github_enterprise_url'); | ||
| if (is_string($enterpriseUrl)) { | ||
| $host = parse_url($enterpriseUrl, PHP_URL_HOST); | ||
| return is_string($host) && str_contains($url, $host); | ||
| } | ||
| return false; | ||
| } |
Collaborator
There was a problem hiding this comment.
This is a duplicate of isGitHubUrl() in app/cdash/app/Lib/Repository/GitHub.php. Let's remove the one in app/cdash/app/Lib/Repository/GitHub.php.
Comment on lines
+162
to
+175
| $enterpriseUrl = config('cdash.github_enterprise_url'); | ||
| if (is_string($enterpriseUrl)) { | ||
| $host = parse_url($enterpriseUrl, PHP_URL_HOST); | ||
| if (is_string($host)) { | ||
| $idx = strpos($github_url, $host); | ||
| if ($idx !== false) { | ||
| // For GHE, ...://<host>/<user>/<repo> becomes ...://<host>/api/v3/repos/<user>/<repo> | ||
| $idx2 = $idx + strlen($host) + 1; | ||
| $api_url = substr($github_url, 0, $idx) . $host . '/api/v3/repos/'; | ||
| $api_url .= substr($github_url, $idx2); | ||
| return $api_url; | ||
| } | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
A few questions/comments:
- Can you please add a comment explaining what's going on here?
- Does
...<host>/api/v3...work for GitHub.com too? i.e., are we strictly required to have a GHE-specific code path here? - Assuming we need a GHE-specific code path, can you wrap the following code in an
elseso it's clear that there are two branches? It took a second for me to understand what was going on here. - There are probably Laravel string facade methods which could make this cleaner.
Collaborator
|
@arhowe00 Note that CDash squashes commits, so your PR description will be included in the git history permanently. Please leave any questions/comments as comments on GitHub and treat the PR description as the commit message. |
Centralizes config('cdash.github_enterprise_url') access into a single
RepositoryUtils::getEnterpriseUrl() method that returns null for both
null and empty string values, preventing empty strings from being
passed to the GitHub API client constructor.
Keep the single copy in RepositoryUtils (now public) and call it from the GitHub class constructor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for GitHub Enterprise Server (GHE) so CDash can post check runs and commit statuses to self-hosted GHE instances
GITHUB_ENTERPRISE_URL, when set, will have CDash target that instance for GitHub API interactions