Fall back to gzip if zstd fails
This commit is contained in:
parent
662c71aa9e
commit
4d015b8cba
6 changed files with 82 additions and 33 deletions
27
lib/setup-codeql.js
generated
27
lib/setup-codeql.js
generated
|
|
@ -198,7 +198,7 @@ async function findOverridingToolsInCache(humanReadableVersion, logger) {
|
|||
}
|
||||
return undefined;
|
||||
}
|
||||
async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, zstdAvailability, features, logger) {
|
||||
async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, tarSupportsZstd, features, logger) {
|
||||
if (toolsInput &&
|
||||
!CODEQL_BUNDLE_VERSION_ALIAS.includes(toolsInput) &&
|
||||
!toolsInput.startsWith("http")) {
|
||||
|
|
@ -341,7 +341,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
|
|||
}
|
||||
if (!url) {
|
||||
url = await getCodeQLBundleDownloadURL(tagName, apiDetails, cliVersion !== undefined &&
|
||||
(await useZstdBundle(cliVersion, features, zstdAvailability)), logger);
|
||||
(await useZstdBundle(cliVersion, features, tarSupportsZstd)), logger);
|
||||
}
|
||||
if (cliVersion) {
|
||||
logger.info(`Using CodeQL CLI version ${cliVersion} sourced from ${url}.`);
|
||||
|
|
@ -479,7 +479,20 @@ function getCanonicalToolcacheVersion(cliVersion, bundleVersion, logger) {
|
|||
*/
|
||||
async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger) {
|
||||
const zstdAvailability = await tar.isZstdAvailable(logger);
|
||||
const source = await getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, zstdAvailability, features, logger);
|
||||
// If we think the installed version of tar supports zstd, try to use zstd,
|
||||
// but be prepared to fall back to gzip in case we were wrong.
|
||||
if (zstdAvailability.available) {
|
||||
try {
|
||||
return await setupCodeQLBundleWithCompressionMethod(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger, zstdAvailability, true);
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to set up CodeQL tools with zstd. Falling back to gzipped version. Error: ${util.getErrorMessage(e)}`);
|
||||
}
|
||||
}
|
||||
return await setupCodeQLBundleWithCompressionMethod(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger, zstdAvailability, false);
|
||||
}
|
||||
async function setupCodeQLBundleWithCompressionMethod(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger, zstdAvailability, useTarIfAvailable) {
|
||||
const source = await getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, variant, useTarIfAvailable, features, logger);
|
||||
let codeqlFolder;
|
||||
let toolsVersion = source.toolsVersion;
|
||||
let toolsDownloadStatusReport;
|
||||
|
|
@ -538,9 +551,9 @@ function sanitizeUrlForStatusReport(url) {
|
|||
? url
|
||||
: "sanitized-value";
|
||||
}
|
||||
async function useZstdBundle(cliVersion, features, zstdAvailability) {
|
||||
return (semver.gte(cliVersion, "2.19.0") &&
|
||||
!!(await features.getValue(feature_flags_1.Feature.ZstdBundle)) &&
|
||||
zstdAvailability.available);
|
||||
async function useZstdBundle(cliVersion, features, tarSupportsZstd) {
|
||||
return (tarSupportsZstd &&
|
||||
semver.gte(cliVersion, "2.19.0") &&
|
||||
!!(await features.getValue(feature_flags_1.Feature.ZstdBundle)));
|
||||
}
|
||||
//# sourceMappingURL=setup-codeql.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue