mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Extract the default bundle sources from selectDefaultBundle
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
19
lib/entry-points.js
generated
19
lib/entry-points.js
generated
@@ -152229,8 +152229,7 @@ function getCodeQLActionRepository(logger) {
|
||||
}
|
||||
return getRequiredEnvParam("GITHUB_ACTION_REPOSITORY");
|
||||
}
|
||||
async function selectDefaultBundle(action, tagName, apiDetails, options) {
|
||||
const { logger } = action;
|
||||
function getDefaultBundleSources(apiDetails, logger) {
|
||||
const codeQLActionRepository = getCodeQLActionRepository(logger);
|
||||
const potentialDownloadSources = [
|
||||
// This GitHub instance, and this Action.
|
||||
@@ -152240,12 +152239,16 @@ async function selectDefaultBundle(action, tagName, apiDetails, options) {
|
||||
// GitHub.com, and the canonical Action.
|
||||
[GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY]
|
||||
];
|
||||
const uniqueDownloadSources = potentialDownloadSources.filter(
|
||||
(source, index2, self2) => {
|
||||
return !self2.slice(0, index2).some((other) => (0, import_fast_deep_equal.default)(source, other));
|
||||
}
|
||||
);
|
||||
for (const [serverURL, repository] of uniqueDownloadSources) {
|
||||
return potentialDownloadSources.filter((source, index2, self2) => {
|
||||
return !self2.slice(0, index2).some((other) => (0, import_fast_deep_equal.default)(source, other));
|
||||
});
|
||||
}
|
||||
async function selectDefaultBundle(action, tagName, apiDetails, options) {
|
||||
const { logger } = action;
|
||||
for (const [serverURL, repository] of getDefaultBundleSources(
|
||||
apiDetails,
|
||||
logger
|
||||
)) {
|
||||
if (serverURL === GITHUB_DOTCOM_URL && repository === CODEQL_DEFAULT_ACTION_REPOSITORY) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,27 @@ export function getCodeQLActionRepository(logger: Logger): string {
|
||||
return util.getRequiredEnvParam("GITHUB_ACTION_REPOSITORY");
|
||||
}
|
||||
|
||||
/** Returns the repositories that release the default bundles, most preferred first. */
|
||||
function getDefaultBundleSources(
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
logger: Logger,
|
||||
): Array<[serverURL: string, repository: string]> {
|
||||
const codeQLActionRepository = getCodeQLActionRepository(logger);
|
||||
const potentialDownloadSources: Array<[string, string]> = [
|
||||
// This GitHub instance, and this Action.
|
||||
[apiDetails.url, codeQLActionRepository],
|
||||
// This GitHub instance, and the canonical Action.
|
||||
[apiDetails.url, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||
// GitHub.com, and the canonical Action.
|
||||
[util.GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||
];
|
||||
// We now filter out any duplicates.
|
||||
// Duplicates will happen either because the GitHub instance is GitHub.com, or because the Action is not a fork.
|
||||
return potentialDownloadSources.filter((source, index, self) => {
|
||||
return !self.slice(0, index).some((other) => deepEqual(source, other));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a bundle from the first release tagged `tagName` that has a compatible bundle, trying the
|
||||
* Action repositories on this GitHub instance before the canonical Action on GitHub.com. If we
|
||||
@@ -106,23 +127,10 @@ async function selectDefaultBundle(
|
||||
options: BundleSelectionOptions,
|
||||
): Promise<BundleSelection> {
|
||||
const { logger } = action;
|
||||
const codeQLActionRepository = getCodeQLActionRepository(logger);
|
||||
const potentialDownloadSources = [
|
||||
// This GitHub instance, and this Action.
|
||||
[apiDetails.url, codeQLActionRepository],
|
||||
// This GitHub instance, and the canonical Action.
|
||||
[apiDetails.url, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||
// GitHub.com, and the canonical Action.
|
||||
[util.GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||
];
|
||||
// We now filter out any duplicates.
|
||||
// Duplicates will happen either because the GitHub instance is GitHub.com, or because the Action is not a fork.
|
||||
const uniqueDownloadSources = potentialDownloadSources.filter(
|
||||
(source, index, self) => {
|
||||
return !self.slice(0, index).some((other) => deepEqual(source, other));
|
||||
},
|
||||
);
|
||||
for (const [serverURL, repository] of uniqueDownloadSources) {
|
||||
for (const [serverURL, repository] of getDefaultBundleSources(
|
||||
apiDetails,
|
||||
logger,
|
||||
)) {
|
||||
// If we've reached the final case, short-circuit the API check since we know the bundle exists and is public.
|
||||
if (
|
||||
serverURL === util.GITHUB_DOTCOM_URL &&
|
||||
|
||||
Reference in New Issue
Block a user