Improve duration formatting

This commit is contained in:
Henry Mercer 2024-10-10 19:09:47 +01:00
parent edd7713837
commit 222ac621e3
9 changed files with 49 additions and 14 deletions

7
lib/tools-download.js generated
View file

@ -30,6 +30,7 @@ const toolcache = __importStar(require("@actions/tool-cache"));
const follow_redirects_1 = require("follow-redirects");
const uuid_1 = require("uuid");
const feature_flags_1 = require("./feature-flags");
const logging_1 = require("./logging");
const tar = __importStar(require("./tar"));
const util_1 = require("./util");
async function downloadAndExtract(codeqlURL, authorization, headers, tarVersion, tempDir, features, logger) {
@ -41,7 +42,7 @@ async function downloadAndExtract(codeqlURL, authorization, headers, tarVersion,
const toolsInstallStart = perf_hooks_1.performance.now();
const extractedBundlePath = await downloadAndExtractZstdWithStreaming(codeqlURL, authorization, headers, tarVersion, logger);
const combinedDurationMs = Math.round(perf_hooks_1.performance.now() - toolsInstallStart);
logger.info(`Finished downloading and extracting CodeQL bundle to ${extractedBundlePath} (${combinedDurationMs} ms).`);
logger.info(`Finished downloading and extracting CodeQL bundle to ${extractedBundlePath} (${(0, logging_1.formatDuration)(combinedDurationMs)}).`);
return {
extractedBundlePath,
statusReport: {
@ -57,7 +58,7 @@ async function downloadAndExtract(codeqlURL, authorization, headers, tarVersion,
const toolsDownloadStart = perf_hooks_1.performance.now();
const archivedBundlePath = await toolcache.downloadTool(codeqlURL, dest, authorization, headers);
const downloadDurationMs = Math.round(perf_hooks_1.performance.now() - toolsDownloadStart);
logger.info(`Finished downloading CodeQL bundle to ${archivedBundlePath} (${downloadDurationMs} ms).`);
logger.info(`Finished downloading CodeQL bundle to ${archivedBundlePath} (${(0, logging_1.formatDuration)(downloadDurationMs)}).`);
let extractedBundlePath;
let extractionDurationMs;
try {
@ -65,7 +66,7 @@ async function downloadAndExtract(codeqlURL, authorization, headers, tarVersion,
const extractionStart = perf_hooks_1.performance.now();
extractedBundlePath = await tar.extract(archivedBundlePath, compressionMethod, tarVersion, logger);
extractionDurationMs = Math.round(perf_hooks_1.performance.now() - extractionStart);
logger.info(`Finished extracting CodeQL bundle to ${extractedBundlePath} (${extractionDurationMs} ms).`);
logger.info(`Finished extracting CodeQL bundle to ${extractedBundlePath} (${(0, logging_1.formatDuration)(extractionDurationMs)}).`);
}
finally {
await (0, util_1.cleanUpGlob)(archivedBundlePath, "CodeQL bundle archive", logger);