Delete bundle archive after extracting it

This commit is contained in:
Henry Mercer 2023-08-01 17:49:21 +01:00
parent e7e35baaf0
commit 38adb40e7a
3 changed files with 24 additions and 3 deletions

11
lib/setup-codeql.js generated
View file

@ -31,6 +31,7 @@ const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const perf_hooks_1 = require("perf_hooks");
const toolcache = __importStar(require("@actions/tool-cache"));
const del_1 = __importDefault(require("del"));
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
const semver = __importStar(require("semver"));
const uuid_1 = require("uuid");
@ -422,8 +423,16 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
const toolsDownloadStart = perf_hooks_1.performance.now();
const codeqlPath = await toolcache.downloadTool(codeqlURL, dest, authorization, finalHeaders);
const toolsDownloadDurationMs = Math.round(perf_hooks_1.performance.now() - toolsDownloadStart);
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
logger.debug(`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`);
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
logger.debug(`Finished extracting CodeQL bundle to ${codeqlExtracted}.`);
try {
await (0, del_1.default)(codeqlPath, { force: true });
logger.debug("Deleted CodeQL bundle archive.");
}
catch (e) {
logger.warning("Failed to delete CodeQL bundle archive.");
}
const bundleVersion = maybeBundleVersion ?? tryGetBundleVersionFromUrl(codeqlURL, logger);
if (bundleVersion === undefined) {
logger.debug("Could not cache CodeQL tools because we could not determine the bundle version from the " +

File diff suppressed because one or more lines are too long

View file

@ -4,6 +4,7 @@ import * as path from "path";
import { performance } from "perf_hooks";
import * as toolcache from "@actions/tool-cache";
import del from "del";
import { default as deepEqual } from "fast-deep-equal";
import * as semver from "semver";
import { v4 as uuidV4 } from "uuid";
@ -569,10 +570,21 @@ export async function downloadCodeQL(
performance.now() - toolsDownloadStart,
);
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
logger.debug(
`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`,
);
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
logger.debug(`Finished extracting CodeQL bundle to ${codeqlExtracted}.`);
try {
await del(codeqlPath, { force: true });
logger.debug("Deleted CodeQL bundle archive.");
} catch (e) {
logger.warning("Failed to delete CodeQL bundle archive.");
}
const bundleVersion =
maybeBundleVersion ?? tryGetBundleVersionFromUrl(codeqlURL, logger);