Fall back to gzipped bundles

This commit is contained in:
Henry Mercer
2024-08-13 13:55:19 +01:00
parent 8e444360fd
commit d277fb19ed
9 changed files with 108 additions and 46 deletions

17
lib/setup-codeql.js generated
View File

@@ -48,7 +48,6 @@ 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 util = __importStar(require("./util"));
const util_1 = require("./util");
var ToolsSource;
@@ -76,8 +75,8 @@ function getCodeQLBundleBaseName() {
}
return `codeql-bundle-${platform}`;
}
async function getCodeQLBundleName(features) {
if (await features.getValue(feature_flags_1.Feature.ZstdBundle)) {
async function getCodeQLBundleName(useStdBundle) {
if (useStdBundle) {
return `${getCodeQLBundleBaseName()}.tar.zst`;
}
return `${getCodeQLBundleBaseName()}.tar.gz`;
@@ -92,7 +91,7 @@ function getCodeQLActionRepository(logger) {
}
return util.getRequiredEnvParam("GITHUB_ACTION_REPOSITORY");
}
async function getCodeQLBundleDownloadURL(tagName, apiDetails, features, logger) {
async function getCodeQLBundleDownloadURL(tagName, apiDetails, useStdBundle, logger) {
const codeQLActionRepository = getCodeQLActionRepository(logger);
const potentialDownloadSources = [
// This GitHub instance, and this Action.
@@ -107,7 +106,7 @@ async function getCodeQLBundleDownloadURL(tagName, apiDetails, features, 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 = await getCodeQLBundleName(features);
const codeQLBundleName = await getCodeQLBundleName(useStdBundle);
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.
@@ -199,7 +198,7 @@ async function findOverridingToolsInCache(humanReadableVersion, logger) {
}
return undefined;
}
async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, features, logger) {
async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, useStdBundle, logger) {
if (toolsInput &&
!CODEQL_BUNDLE_VERSION_ALIAS.includes(toolsInput) &&
!toolsInput.startsWith("http")) {
@@ -341,7 +340,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
}
}
if (!url) {
url = await getCodeQLBundleDownloadURL(tagName, apiDetails, features, logger);
url = await getCodeQLBundleDownloadURL(tagName, apiDetails, useStdBundle, logger);
}
if (cliVersion) {
logger.info(`Using CodeQL CLI version ${cliVersion} sourced from ${url}.`);
@@ -480,8 +479,8 @@ function getCanonicalToolcacheVersion(cliVersion, bundleVersion, logger) {
* version requirement. Must be set to true outside tests.
* @returns the path to the extracted bundle, and the version of the tools
*/
async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger) {
const source = await getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, features, logger);
async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, useStdBundle, logger) {
const source = await getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, useStdBundle, logger);
let codeqlFolder;
let toolsVersion = source.toolsVersion;
let toolsDownloadStatusReport;