Add explicit field for extraction streaming

This commit is contained in:
Henry Mercer 2024-10-10 19:54:56 +01:00
parent 4dca88a5fc
commit 565880b86a
6 changed files with 54 additions and 14 deletions

View file

@ -165,6 +165,7 @@ test("setupCodeQLBundle logs the CodeQL CLI version being used when asked to use
compressionMethod: "gzip",
downloadDurationMs: 200,
extractionDurationMs: 300,
streamExtraction: false,
toolsUrl: "toolsUrl",
},
toolsVersion: LINKED_CLI_VERSION.cliVersion,
@ -215,6 +216,7 @@ test("setupCodeQLBundle logs the CodeQL CLI version being used when asked to dow
compressionMethod: "gzip",
downloadDurationMs: 200,
extractionDurationMs: 300,
streamExtraction: false,
toolsUrl: bundleUrl,
},
toolsVersion: expectedVersion,

View file

@ -19,8 +19,21 @@ type DownloadFirstToolsDownloadDurations = {
combinedDurationMs: number;
downloadDurationMs: number;
extractionDurationMs: number;
streamExtraction: false;
};
function makeDownloadFirstToolsDownloadDurations(
downloadDurationMs: number,
extractionDurationMs: number,
): DownloadFirstToolsDownloadDurations {
return {
combinedDurationMs: downloadDurationMs + extractionDurationMs,
downloadDurationMs,
extractionDurationMs,
streamExtraction: false,
};
}
/**
* Timing information for the download and extraction of the CodeQL tools when
* we stream the download and extraction of the bundle.
@ -29,8 +42,20 @@ type StreamedToolsDownloadDurations = {
combinedDurationMs: number;
downloadDurationMs: undefined;
extractionDurationMs: undefined;
streamExtraction: true;
};
function makeStreamedToolsDownloadDurations(
combinedDurationMs: number,
): StreamedToolsDownloadDurations {
return {
combinedDurationMs,
downloadDurationMs: undefined,
extractionDurationMs: undefined,
streamExtraction: true,
};
}
type ToolsDownloadDurations =
| DownloadFirstToolsDownloadDurations
| StreamedToolsDownloadDurations;
@ -86,11 +111,9 @@ export async function downloadAndExtract(
return {
extractedBundlePath,
statusReport: {
combinedDurationMs,
compressionMethod,
downloadDurationMs: undefined,
extractionDurationMs: undefined,
toolsUrl: sanitizeUrlForStatusReport(codeqlURL),
...makeStreamedToolsDownloadDurations(combinedDurationMs),
},
};
}
@ -138,10 +161,11 @@ export async function downloadAndExtract(
extractedBundlePath,
statusReport: {
compressionMethod,
combinedDurationMs: downloadDurationMs + extractionDurationMs,
downloadDurationMs,
extractionDurationMs,
toolsUrl: sanitizeUrlForStatusReport(codeqlURL),
...makeDownloadFirstToolsDownloadDurations(
downloadDurationMs,
extractionDurationMs,
),
},
};
}