Skip to content

Commit b2bf750

Browse files
committed
Include apiDetails in CodeQLDownloadSource
1 parent f2547e0 commit b2bf750

4 files changed

Lines changed: 18 additions & 26 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 6 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/codeql-bundle.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { GitHubApiDetails } from "./github";
12
import { BuiltInLanguage, parseBuiltInLanguage } from "./languages";
23
import { BundlePlatform } from "./platform";
34
import type { CompressionMethod } from "./tar";
@@ -17,6 +18,8 @@ export type CodeQLBundle =
1718
export interface CodeQLDownloadSource {
1819
/** Distinguishes downloads from local archives and cached installations. */
1920
sourceType: "download";
21+
/** Information about the GitHub instance that contains the asset. */
22+
apiDetails: GitHubApiDetails;
2023
/** The bundle to download. */
2124
bundle: CodeQLBundle;
2225
/** The compression format of the bundle archive. */

‎src/setup-codeql.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ test.serial(
156156
compressionMethod: "gzip",
157157
sourceType: "download",
158158
toolsVersion: "1.2.3",
159+
apiDetails: SAMPLE_DOTCOM_API_DETAILS,
159160
} satisfies setupCodeql.CodeQLDownloadSource);
160161
});
161162
},
@@ -435,6 +436,7 @@ test.serial(
435436
compressionMethod: "zstd",
436437
sourceType: "download",
437438
toolsVersion: expectedVersion,
439+
apiDetails: SAMPLE_DOTCOM_API_DETAILS,
438440
} satisfies setupCodeql.CodeQLToolsSource);
439441

440442
const result = await setupCodeql.setupCodeQLBundle(
@@ -508,6 +510,7 @@ test.serial(
508510
compressionMethod: "zstd",
509511
sourceType: "download",
510512
toolsVersion: expectedVersion,
513+
apiDetails: SAMPLE_DOTCOM_API_DETAILS,
511514
} satisfies setupCodeql.CodeQLToolsSource);
512515

513516
// Afterwards, ensure that we see the expected messages in the log.
@@ -655,6 +658,7 @@ for (const toolsInput of ["nightly", "nightly-latest"]) {
655658
cliVersion: undefined,
656659
compressionMethod: "zstd",
657660
toolsVersion: "0.0.0-30260213",
661+
apiDetails: SAMPLE_DOTCOM_API_DETAILS,
658662
} satisfies setupCodeql.CodeQLDownloadSource);
659663
t.true(latestNightlyRequest.calledOnce);
660664
});
@@ -807,6 +811,7 @@ for (const date of ["20200101", "30260213"]) {
807811
cliVersion: undefined,
808812
compressionMethod: "zstd",
809813
toolsVersion: `0.0.0-${date}`,
814+
apiDetails: SAMPLE_DOTCOM_API_DETAILS,
810815
} satisfies setupCodeql.CodeQLDownloadSource);
811816

812817
await t.throwsAsync(
@@ -1864,8 +1869,8 @@ async function runDownloadCodeQL(
18641869
cliVersion: CLEANUP_CLI_VERSION,
18651870
sourceType: "download",
18661871
toolsVersion: CLEANUP_CLI_VERSION,
1872+
apiDetails: SAMPLE_DOTCOM_API_DETAILS,
18671873
},
1868-
SAMPLE_DOTCOM_API_DETAILS,
18691874
undefined, // tarVersion
18701875
toolcacheRoot, // tempDir
18711876
);

‎src/setup-codeql.ts‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ export async function getCodeQLSource(
718718
compressionMethod,
719719
sourceType: "download",
720720
toolsVersion: resolvedVersion ?? "unknown",
721+
apiDetails,
721722
};
722723
}
723724

@@ -746,7 +747,6 @@ async function tryGetFallbackToolcacheVersion(
746747
// be able to stub this function and have other functions in this file use that stub.
747748
export const downloadCodeQL = async function (
748749
source: CodeQLDownloadSource,
749-
apiDetails: api.GitHubApiDetails,
750750
tarVersion: tar.TarVersion | undefined,
751751
tempDir: string,
752752
logger: Logger,
@@ -769,7 +769,7 @@ export const downloadCodeQL = async function (
769769
} else {
770770
authorization = api.getAuthorizationHeaderFor(
771771
logger,
772-
apiDetails,
772+
source.apiDetails,
773773
codeqlURL,
774774
);
775775
}
@@ -985,7 +985,6 @@ export async function setupCodeQLBundle(
985985
const result = await downloadCodeQLBundle(
986986
{ env: getEnv(), features, logger },
987987
source,
988-
apiDetails,
989988
zstdAvailability.version,
990989
tempDir,
991990
);
@@ -1021,7 +1020,6 @@ export async function setupCodeQLBundle(
10211020
export async function downloadCodeQLBundle(
10221021
action: ActionState<["Logger", "ReadOnlyEnv", "FeatureFlags"]>,
10231022
source: CodeQLDownloadSource,
1024-
apiDetails: api.GitHubApiDetails,
10251023
tarVersion: tar.TarVersion | undefined,
10261024
tempDir: string,
10271025
): Promise<{
@@ -1035,13 +1033,7 @@ export async function downloadCodeQLBundle(
10351033

10361034
const startTime = performance.now();
10371035
try {
1038-
return await downloadCodeQL(
1039-
source,
1040-
apiDetails,
1041-
tarVersion,
1042-
tempDir,
1043-
logger,
1044-
);
1036+
return await downloadCodeQL(source, tarVersion, tempDir, logger);
10451037
} catch (e) {
10461038
if (
10471039
bundle.kind !== "per-language" ||
@@ -1057,7 +1049,6 @@ export async function downloadCodeQLBundle(
10571049
...source,
10581050
bundle: { kind: "combined", url: bundle.combinedBundleURL },
10591051
},
1060-
apiDetails,
10611052
tarVersion,
10621053
tempDir,
10631054
logger,

0 commit comments

Comments
 (0)