Capture reason if zstd fails unexpectedly
This commit is contained in:
parent
4d015b8cba
commit
0abc1ec90b
5 changed files with 226 additions and 3 deletions
|
|
@ -486,6 +486,7 @@ export interface ToolsDownloadStatusReport {
|
|||
downloadDurationMs: number;
|
||||
extractionDurationMs: number;
|
||||
toolsUrl: string;
|
||||
zstdFailureReason?: string;
|
||||
}
|
||||
|
||||
// Exported using `export const` for testing purposes. Specifically, we want to
|
||||
|
|
@ -655,6 +656,7 @@ export interface SetupCodeQLResult {
|
|||
toolsSource: ToolsSource;
|
||||
toolsVersion: string;
|
||||
zstdAvailability: tar.ZstdAvailability;
|
||||
zstdFailureReason?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -672,11 +674,18 @@ export async function setupCodeQLBundle(
|
|||
logger: Logger,
|
||||
): Promise<SetupCodeQLResult> {
|
||||
const zstdAvailability = await tar.isZstdAvailable(logger);
|
||||
let zstdFailureReason: string | undefined;
|
||||
|
||||
// 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 {
|
||||
// To facilitate testing the fallback, fail here if a testing environment variable is set.
|
||||
if (process.env.CODEQL_ACTION_FORCE_ZSTD_FAILURE === "true") {
|
||||
throw new Error(
|
||||
"Failing since CODEQL_ACTION_FORCE_ZSTD_FAILURE is true.",
|
||||
);
|
||||
}
|
||||
return await setupCodeQLBundleWithCompressionMethod(
|
||||
toolsInput,
|
||||
apiDetails,
|
||||
|
|
@ -689,6 +698,7 @@ export async function setupCodeQLBundle(
|
|||
true,
|
||||
);
|
||||
} catch (e) {
|
||||
zstdFailureReason = util.getErrorMessage(e) || "unknown error";
|
||||
logger.warning(
|
||||
`Failed to set up CodeQL tools with zstd. Falling back to gzipped version. Error: ${util.getErrorMessage(
|
||||
e,
|
||||
|
|
@ -697,7 +707,7 @@ export async function setupCodeQLBundle(
|
|||
}
|
||||
}
|
||||
|
||||
return await setupCodeQLBundleWithCompressionMethod(
|
||||
const result = await setupCodeQLBundleWithCompressionMethod(
|
||||
toolsInput,
|
||||
apiDetails,
|
||||
tempDir,
|
||||
|
|
@ -708,6 +718,10 @@ export async function setupCodeQLBundle(
|
|||
zstdAvailability,
|
||||
false,
|
||||
);
|
||||
if (result.toolsDownloadStatusReport && zstdFailureReason) {
|
||||
result.toolsDownloadStatusReport.zstdFailureReason = zstdFailureReason;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function setupCodeQLBundleWithCompressionMethod(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue