diff --git a/lib/entry-points.js b/lib/entry-points.js index ca89d1581..a6590f0bd 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -152024,9 +152024,6 @@ var CODEQL_NIGHTLIES_REPOSITORY_NAME = "codeql-cli-nightlies"; var CODEQL_BUNDLE_VERSION_ALIAS = ["linked", "latest"]; var CODEQL_NIGHTLY_TOOLS_INPUTS = ["nightly", "nightly-latest"]; var CODEQL_TOOLCACHE_INPUT = "toolcache"; -function getCodeQLBundleName2(compressionMethod, language) { - return getCodeQLBundleName(compressionMethod, getBundlePlatform(), language); -} function getCodeQLActionRepository(logger) { if (isRunningLocalAction()) { logger.info( @@ -152435,20 +152432,21 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, rawLanguages, useO ); } compressionMethod = cliVersion2 !== void 0 && await useZstdBundle(cliVersion2, tarSupportsZstd) ? "zstd" : "gzip"; + const platform2 = getBundlePlatform(); const perLanguageBundleLanguage = await getPerLanguageBundleLanguage( { env: getEnv(), features, logger }, { rawLanguages, cliVersion: cliVersion2, compressionMethod, - platform: getBundlePlatform(), + platform: platform2, variant } ); const resolveBundleURL = (language) => getCodeQLBundleDownloadURL( bundleTagName, apiDetails, - getCodeQLBundleName2(compressionMethod, language), + getCodeQLBundleName(compressionMethod, platform2, language), logger ); const combinedBundleURL = await resolveBundleURL(); @@ -152718,11 +152716,12 @@ async function getLatestNightlyBundle(action, rawLanguages, variant) { CODEQL_VERSION_ZSTD_BUNDLE, zstdAvailability.available ) ? "zstd" : "gzip"; + const platform2 = getBundlePlatform(); const language = await getPerLanguageBundleLanguage(action, { rawLanguages, cliVersion: void 0, compressionMethod, - platform: getBundlePlatform(), + platform: platform2, variant, isLatestNightly: true }); @@ -152739,12 +152738,16 @@ async function getLatestNightlyBundle(action, rawLanguages, variant) { throw new Error("Could not find the latest nightly release."); } const assetUrl = (name) => `https://github.com/${CODEQL_NIGHTLIES_REPOSITORY_OWNER}/${CODEQL_NIGHTLIES_REPOSITORY_NAME}/releases/download/${latestRelease.tag_name}/${name}`; - const url2 = assetUrl(getCodeQLBundleName2(compressionMethod, language)); + const url2 = assetUrl( + getCodeQLBundleName(compressionMethod, platform2, language) + ); return language === void 0 ? { kind: "combined", url: url2 } : { kind: "per-language", url: url2, language, - combinedBundleURL: assetUrl(getCodeQLBundleName2(compressionMethod)) + combinedBundleURL: assetUrl( + getCodeQLBundleName(compressionMethod, platform2) + ) }; } catch (e) { throw new Error( diff --git a/src/codeql-bundle.test.ts b/src/codeql-bundle.test.ts index 1014043ea..e528ee76f 100644 --- a/src/codeql-bundle.test.ts +++ b/src/codeql-bundle.test.ts @@ -1,7 +1,26 @@ import test from "ava"; -import { getCodeQLBundleFromUrl } from "./codeql-bundle"; +import { getCodeQLBundleFromUrl, getCodeQLBundleName } from "./codeql-bundle"; import { BuiltInLanguage } from "./languages"; +import { BundlePlatform } from "./platform"; + +test("getCodeQLBundleName returns a per-language bundle name only when a language is specified", (t) => { + t.is( + getCodeQLBundleName("zstd", BundlePlatform.Linux64, BuiltInLanguage.java), + "codeql-bundle-java-linux64.tar.zst", + ); + t.is( + getCodeQLBundleName("zstd", BundlePlatform.Linux64), + "codeql-bundle-linux64.tar.zst", + ); +}); + +test("getCodeQLBundleName names the Swift bundle for macOS", (t) => { + t.is( + getCodeQLBundleName("zstd", BundlePlatform.Osx64, BuiltInLanguage.swift), + "codeql-bundle-swift-osx64.tar.zst", + ); +}); for (const [assetName, language] of [ ["codeql-bundle-java-linux64.tar.zst", BuiltInLanguage.java], diff --git a/src/setup-codeql.test.ts b/src/setup-codeql.test.ts index 6ac5bebf1..c33ac0700 100644 --- a/src/setup-codeql.test.ts +++ b/src/setup-codeql.test.ts @@ -435,7 +435,7 @@ test.serial( // Check that the `CodeQLToolsSource` object matches our expectations. const expectedVersion = `0.0.0-${expectedDate}`; - const expectedURL = `https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/${expectedTag}/${setupCodeql.getCodeQLBundleName("zstd")}`; + const expectedURL = `https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/${expectedTag}/codeql-bundle-linux64.tar.zst`; t.deepEqual(source, { bundle: { kind: "combined", url: expectedURL }, bundleVersion: expectedDate, @@ -505,7 +505,7 @@ test.serial( // Check that the `CodeQLToolsSource` object matches our expectations. const expectedVersion = `0.0.0-${expectedDate}`; - const expectedURL = `https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/${expectedTag}/${setupCodeql.getCodeQLBundleName("zstd")}`; + const expectedURL = `https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/${expectedTag}/codeql-bundle-linux64.tar.zst`; t.deepEqual(source, { bundle: { kind: "combined", url: expectedURL }, bundleVersion: expectedDate, @@ -1143,30 +1143,6 @@ const PER_LANGUAGE_CLI_VERSION = { ], }; -test.serial( - "getCodeQLBundleName returns a per-language bundle name only when a language is specified", - (t) => { - sinon.stub(process, "platform").value("linux"); - sinon.stub(process, "arch").value("x64"); - t.is( - setupCodeql.getCodeQLBundleName("zstd", BuiltInLanguage.java), - "codeql-bundle-java-linux64.tar.zst", - ); - t.is( - setupCodeql.getCodeQLBundleName("zstd"), - "codeql-bundle-linux64.tar.zst", - ); - }, -); - -test.serial("getCodeQLBundleName names the Swift bundle for macOS", (t) => { - sinon.stub(process, "platform").value("darwin"); - t.is( - setupCodeql.getCodeQLBundleName("zstd", BuiltInLanguage.swift), - "codeql-bundle-swift-osx64.tar.zst", - ); -}); - test.serial( "getCodeQLSource downloads the per-language bundle for a single explicit language", async (t) => { diff --git a/src/setup-codeql.ts b/src/setup-codeql.ts index 58f37d638..d306d40d6 100644 --- a/src/setup-codeql.ts +++ b/src/setup-codeql.ts @@ -21,7 +21,7 @@ import { CodeQLBundle, CodeQLDownloadSource, getCodeQLBundleFromUrl, - getCodeQLBundleName as getBundleName, + getCodeQLBundleName, } from "./codeql-bundle"; import * as defaults from "./defaults.json"; import { @@ -74,19 +74,6 @@ const CODEQL_BUNDLE_VERSION_ALIAS: string[] = ["linked", "latest"]; const CODEQL_NIGHTLY_TOOLS_INPUTS = ["nightly", "nightly-latest"]; const CODEQL_TOOLCACHE_INPUT = "toolcache"; -/** - * Returns the name of the CodeQL bundle asset to download. - * - * @param compressionMethod The compression method of the bundle. - * @param language Optional language for a per-language bundle. If omitted, returns a combined bundle name. - */ -export function getCodeQLBundleName( - compressionMethod: tar.CompressionMethod, - language?: BuiltInLanguage, -): string { - return getBundleName(compressionMethod, getBundlePlatform(), language); -} - export function getCodeQLActionRepository(logger: Logger): string { if (isRunningLocalAction()) { // This handles the case where the Action does not come from an Action repository, @@ -729,13 +716,14 @@ export async function getCodeQLSource( ? "zstd" : "gzip"; + const platform = getBundlePlatform(); const perLanguageBundleLanguage = await getPerLanguageBundleLanguage( { env: getEnv(), features, logger }, { rawLanguages, cliVersion, compressionMethod, - platform: getBundlePlatform(), + platform, variant, }, ); @@ -745,7 +733,7 @@ export async function getCodeQLSource( getCodeQLBundleDownloadURL( bundleTagName, apiDetails, - getCodeQLBundleName(compressionMethod, language), + getCodeQLBundleName(compressionMethod, platform, language), logger, ); @@ -1183,11 +1171,12 @@ async function getLatestNightlyBundle( ? "zstd" : "gzip"; + const platform = getBundlePlatform(); const language = await getPerLanguageBundleLanguage(action, { rawLanguages, cliVersion: undefined, compressionMethod, - platform: getBundlePlatform(), + platform, variant, isLatestNightly: true, }); @@ -1209,14 +1198,18 @@ async function getLatestNightlyBundle( } const assetUrl = (name: string) => `https://github.com/${CODEQL_NIGHTLIES_REPOSITORY_OWNER}/${CODEQL_NIGHTLIES_REPOSITORY_NAME}/releases/download/${latestRelease.tag_name}/${name}`; - const url = assetUrl(getCodeQLBundleName(compressionMethod, language)); + const url = assetUrl( + getCodeQLBundleName(compressionMethod, platform, language), + ); return language === undefined ? { kind: "combined", url } : { kind: "per-language", url, language, - combinedBundleURL: assetUrl(getCodeQLBundleName(compressionMethod)), + combinedBundleURL: assetUrl( + getCodeQLBundleName(compressionMethod, platform), + ), }; } catch (e) { throw new Error(