From b2bf75026d97ab337782401fa0d120f524f5541e Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Wed, 14 Oct 2026 11:44:14 +0100 Subject: [PATCH] Include `apiDetails` in `CodeQLDownloadSource` --- lib/entry-points.js | 19 ++++++------------- src/codeql-bundle.ts | 3 +++ src/setup-codeql.test.ts | 7 ++++++- src/setup-codeql.ts | 15 +++------------ 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 9707f1c66..491ace4fb 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -176665,7 +176665,8 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, rawLanguages, othe cliVersion: cliVersion2, compressionMethod, sourceType: "download", - toolsVersion: resolvedVersion ?? "unknown" + toolsVersion: resolvedVersion ?? "unknown", + apiDetails }; } async function tryGetFallbackToolcacheVersion(cliVersion2, tagName, logger2) { @@ -176679,7 +176680,7 @@ async function tryGetFallbackToolcacheVersion(cliVersion2, tagName, logger2) { ); return fallbackVersion; } -var downloadCodeQL = async function(source, apiDetails, tarVersion, tempDir, logger2) { +var downloadCodeQL = async function(source, tarVersion, tempDir, logger2) { const { bundle, compressionMethod } = source; const codeqlURL = bundle.url; const parsedCodeQLURL = new URL(codeqlURL); @@ -176693,7 +176694,7 @@ var downloadCodeQL = async function(source, apiDetails, tarVersion, tempDir, log } else { authorization = getAuthorizationHeaderFor( logger2, - apiDetails, + source.apiDetails, codeqlURL ); } @@ -176817,7 +176818,6 @@ async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defau const result = await downloadCodeQLBundle( { env: getEnv(), features, logger: logger2 }, source, - apiDetails, zstdAvailability.version, tempDir ); @@ -176837,19 +176837,13 @@ async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defau toolsVersion: source.toolsVersion }; } -async function downloadCodeQLBundle(action, source, apiDetails, tarVersion, tempDir) { +async function downloadCodeQLBundle(action, source, tarVersion, tempDir) { const { bundle } = source; const { logger: logger2 } = action; await tryDeleteToolcacheBundles(action); const startTime = import_perf_hooks4.performance.now(); try { - return await downloadCodeQL( - source, - apiDetails, - tarVersion, - tempDir, - logger2 - ); + return await downloadCodeQL(source, tarVersion, tempDir, logger2); } catch (e) { if (bundle.kind !== "per-language" || bundle.combinedBundleURL === void 0 || asHTTPError(e)?.status !== 404) { throw e; @@ -176860,7 +176854,6 @@ async function downloadCodeQLBundle(action, source, apiDetails, tarVersion, temp ...source, bundle: { kind: "combined", url: bundle.combinedBundleURL } }, - apiDetails, tarVersion, tempDir, logger2 diff --git a/src/codeql-bundle.ts b/src/codeql-bundle.ts index 2d262c848..2b6da0029 100644 --- a/src/codeql-bundle.ts +++ b/src/codeql-bundle.ts @@ -1,3 +1,4 @@ +import type { GitHubApiDetails } from "./github"; import { BuiltInLanguage, parseBuiltInLanguage } from "./languages"; import { BundlePlatform } from "./platform"; import type { CompressionMethod } from "./tar"; @@ -17,6 +18,8 @@ export type CodeQLBundle = export interface CodeQLDownloadSource { /** Distinguishes downloads from local archives and cached installations. */ sourceType: "download"; + /** Information about the GitHub instance that contains the asset. */ + apiDetails: GitHubApiDetails; /** The bundle to download. */ bundle: CodeQLBundle; /** The compression format of the bundle archive. */ diff --git a/src/setup-codeql.test.ts b/src/setup-codeql.test.ts index 9ad2c6773..d8c6f32d6 100644 --- a/src/setup-codeql.test.ts +++ b/src/setup-codeql.test.ts @@ -156,6 +156,7 @@ test.serial( compressionMethod: "gzip", sourceType: "download", toolsVersion: "1.2.3", + apiDetails: SAMPLE_DOTCOM_API_DETAILS, } satisfies setupCodeql.CodeQLDownloadSource); }); }, @@ -435,6 +436,7 @@ test.serial( compressionMethod: "zstd", sourceType: "download", toolsVersion: expectedVersion, + apiDetails: SAMPLE_DOTCOM_API_DETAILS, } satisfies setupCodeql.CodeQLToolsSource); const result = await setupCodeql.setupCodeQLBundle( @@ -508,6 +510,7 @@ test.serial( compressionMethod: "zstd", sourceType: "download", toolsVersion: expectedVersion, + apiDetails: SAMPLE_DOTCOM_API_DETAILS, } satisfies setupCodeql.CodeQLToolsSource); // Afterwards, ensure that we see the expected messages in the log. @@ -655,6 +658,7 @@ for (const toolsInput of ["nightly", "nightly-latest"]) { cliVersion: undefined, compressionMethod: "zstd", toolsVersion: "0.0.0-30260213", + apiDetails: SAMPLE_DOTCOM_API_DETAILS, } satisfies setupCodeql.CodeQLDownloadSource); t.true(latestNightlyRequest.calledOnce); }); @@ -807,6 +811,7 @@ for (const date of ["20200101", "30260213"]) { cliVersion: undefined, compressionMethod: "zstd", toolsVersion: `0.0.0-${date}`, + apiDetails: SAMPLE_DOTCOM_API_DETAILS, } satisfies setupCodeql.CodeQLDownloadSource); await t.throwsAsync( @@ -1864,8 +1869,8 @@ async function runDownloadCodeQL( cliVersion: CLEANUP_CLI_VERSION, sourceType: "download", toolsVersion: CLEANUP_CLI_VERSION, + apiDetails: SAMPLE_DOTCOM_API_DETAILS, }, - SAMPLE_DOTCOM_API_DETAILS, undefined, // tarVersion toolcacheRoot, // tempDir ); diff --git a/src/setup-codeql.ts b/src/setup-codeql.ts index 07666d630..6668ef1e7 100644 --- a/src/setup-codeql.ts +++ b/src/setup-codeql.ts @@ -718,6 +718,7 @@ export async function getCodeQLSource( compressionMethod, sourceType: "download", toolsVersion: resolvedVersion ?? "unknown", + apiDetails, }; } @@ -746,7 +747,6 @@ async function tryGetFallbackToolcacheVersion( // be able to stub this function and have other functions in this file use that stub. export const downloadCodeQL = async function ( source: CodeQLDownloadSource, - apiDetails: api.GitHubApiDetails, tarVersion: tar.TarVersion | undefined, tempDir: string, logger: Logger, @@ -769,7 +769,7 @@ export const downloadCodeQL = async function ( } else { authorization = api.getAuthorizationHeaderFor( logger, - apiDetails, + source.apiDetails, codeqlURL, ); } @@ -985,7 +985,6 @@ export async function setupCodeQLBundle( const result = await downloadCodeQLBundle( { env: getEnv(), features, logger }, source, - apiDetails, zstdAvailability.version, tempDir, ); @@ -1021,7 +1020,6 @@ export async function setupCodeQLBundle( export async function downloadCodeQLBundle( action: ActionState<["Logger", "ReadOnlyEnv", "FeatureFlags"]>, source: CodeQLDownloadSource, - apiDetails: api.GitHubApiDetails, tarVersion: tar.TarVersion | undefined, tempDir: string, ): Promise<{ @@ -1035,13 +1033,7 @@ export async function downloadCodeQLBundle( const startTime = performance.now(); try { - return await downloadCodeQL( - source, - apiDetails, - tarVersion, - tempDir, - logger, - ); + return await downloadCodeQL(source, tarVersion, tempDir, logger); } catch (e) { if ( bundle.kind !== "per-language" || @@ -1057,7 +1049,6 @@ export async function downloadCodeQLBundle( ...source, bundle: { kind: "combined", url: bundle.combinedBundleURL }, }, - apiDetails, tarVersion, tempDir, logger,