Use zstd bundle by default when feature flag enabled

This commit is contained in:
Henry Mercer 2024-09-23 19:00:30 +01:00
parent e7309d2b5c
commit ac3fca3e9f
24 changed files with 116 additions and 45 deletions

23
lib/setup-codeql.js generated
View file

@ -48,6 +48,7 @@ const api = __importStar(require("./api-client"));
// creation scripts. Ensure that any changes to the format of this file are compatible with both of
// these dependents.
const defaults = __importStar(require("./defaults.json"));
const feature_flags_1 = require("./feature-flags");
const tar = __importStar(require("./tar"));
const util = __importStar(require("./util"));
const util_1 = require("./util");
@ -60,7 +61,11 @@ var ToolsSource;
})(ToolsSource || (exports.ToolsSource = ToolsSource = {}));
exports.CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
const CODEQL_BUNDLE_VERSION_ALIAS = ["linked", "latest"];
function getCodeQLBundleName() {
function getCodeQLBundleExtension(useZstd) {
return useZstd ? ".tar.zst" : ".tar.gz";
}
function getCodeQLBundleName(useZstd) {
const extension = getCodeQLBundleExtension(useZstd);
let platform;
if (process.platform === "win32") {
platform = "win64";
@ -72,9 +77,9 @@ function getCodeQLBundleName() {
platform = "osx64";
}
else {
return "codeql-bundle.tar.gz";
return `codeql-bundle${extension}`;
}
return `codeql-bundle-${platform}.tar.gz`;
return `codeql-bundle-${platform}${extension}`;
}
function getCodeQLActionRepository(logger) {
if ((0, actions_util_1.isRunningLocalAction)()) {
@ -86,7 +91,7 @@ function getCodeQLActionRepository(logger) {
}
return util.getRequiredEnvParam("GITHUB_ACTION_REPOSITORY");
}
async function getCodeQLBundleDownloadURL(tagName, apiDetails, logger) {
async function getCodeQLBundleDownloadURL(tagName, apiDetails, useZstd, logger) {
const codeQLActionRepository = getCodeQLActionRepository(logger);
const potentialDownloadSources = [
// This GitHub instance, and this Action.
@ -101,7 +106,7 @@ async function getCodeQLBundleDownloadURL(tagName, apiDetails, logger) {
const uniqueDownloadSources = potentialDownloadSources.filter((source, index, self) => {
return !self.slice(0, index).some((other) => (0, fast_deep_equal_1.default)(source, other));
});
const codeQLBundleName = getCodeQLBundleName();
const codeQLBundleName = getCodeQLBundleName(useZstd);
for (const downloadSource of uniqueDownloadSources) {
const [apiURL, repository] = downloadSource;
// If we've reached the final case, short-circuit the API check since we know the bundle exists and is public.
@ -193,7 +198,7 @@ async function findOverridingToolsInCache(humanReadableVersion, logger) {
}
return undefined;
}
async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, logger) {
async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, features, logger) {
if (toolsInput &&
!CODEQL_BUNDLE_VERSION_ALIAS.includes(toolsInput) &&
!toolsInput.startsWith("http")) {
@ -335,7 +340,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
}
}
if (!url) {
url = await getCodeQLBundleDownloadURL(tagName, apiDetails, logger);
url = await getCodeQLBundleDownloadURL(tagName, apiDetails, cliVersion !== undefined && (await (0, feature_flags_1.useZstdBundle)(cliVersion, features)), logger);
}
if (cliVersion) {
logger.info(`Using CodeQL CLI version ${cliVersion} sourced from ${url}.`);
@ -471,8 +476,8 @@ function getCanonicalToolcacheVersion(cliVersion, bundleVersion, logger) {
*
* @returns the path to the extracted bundle, and the version of the tools
*/
async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, logger) {
const source = await getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, logger);
async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger) {
const source = await getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, features, logger);
let codeqlFolder;
let toolsVersion = source.toolsVersion;
let toolsDownloadStatusReport;