mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Remove the getCodeQLBundleName wrapper from setup-codeql.ts
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
@@ -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(
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user