Clean up non-toolcached bundle
This commit is contained in:
parent
ea47b2ae40
commit
f93fb8df6e
3 changed files with 49 additions and 10 deletions
21
lib/setup-codeql.js
generated
21
lib/setup-codeql.js
generated
|
|
@ -424,8 +424,12 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
|
||||||
const codeqlPath = await toolcache.downloadTool(codeqlURL, dest, authorization, finalHeaders);
|
const codeqlPath = await toolcache.downloadTool(codeqlURL, dest, authorization, finalHeaders);
|
||||||
const toolsDownloadDurationMs = Math.round(perf_hooks_1.performance.now() - toolsDownloadStart);
|
const toolsDownloadDurationMs = Math.round(perf_hooks_1.performance.now() - toolsDownloadStart);
|
||||||
logger.debug(`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`);
|
logger.debug(`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`);
|
||||||
|
logger.debug("Extracting CodeQL bundle.");
|
||||||
|
const extractionStart = perf_hooks_1.performance.now();
|
||||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||||
logger.debug(`Finished extracting CodeQL bundle to ${codeqlExtracted}.`);
|
const extractionMs = Math.round(perf_hooks_1.performance.now() - extractionStart);
|
||||||
|
logger.debug(`Finished extracting CodeQL bundle to ${codeqlExtracted} (${extractionMs} ms).`);
|
||||||
|
logger.debug("Cleaning up CodeQL bundle archive.");
|
||||||
try {
|
try {
|
||||||
await (0, del_1.default)(codeqlPath, { force: true });
|
await (0, del_1.default)(codeqlPath, { force: true });
|
||||||
logger.debug("Deleted CodeQL bundle archive.");
|
logger.debug("Deleted CodeQL bundle archive.");
|
||||||
|
|
@ -461,9 +465,22 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
|
||||||
const toolcacheVersion = maybeCliVersion?.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
const toolcacheVersion = maybeCliVersion?.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
||||||
? `${maybeCliVersion}-${bundleVersion}`
|
? `${maybeCliVersion}-${bundleVersion}`
|
||||||
: convertToSemVer(bundleVersion, logger);
|
: convertToSemVer(bundleVersion, logger);
|
||||||
|
logger.debug("Caching CodeQL bundle.");
|
||||||
|
const codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion);
|
||||||
|
// Safety check to make sure that we don't delete the bundle we're about to use.
|
||||||
|
if (codeqlFolder !== codeqlExtracted) {
|
||||||
|
logger.debug("Cleaning up downloaded CodeQL bundle.");
|
||||||
|
try {
|
||||||
|
await (0, del_1.default)(codeqlPath, { force: true });
|
||||||
|
logger.debug("Deleted CodeQL bundle from temporary directory.");
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
logger.warning("Failed to delete CodeQL bundle from temporary directory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
toolsVersion: maybeCliVersion ?? toolcacheVersion,
|
toolsVersion: maybeCliVersion ?? toolcacheVersion,
|
||||||
codeqlFolder: await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion),
|
codeqlFolder,
|
||||||
toolsDownloadDurationMs,
|
toolsDownloadDurationMs,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -574,10 +574,15 @@ export async function downloadCodeQL(
|
||||||
`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`,
|
`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
logger.debug("Extracting CodeQL bundle.");
|
||||||
|
const extractionStart = performance.now();
|
||||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||||
|
const extractionMs = Math.round(performance.now() - extractionStart);
|
||||||
|
logger.debug(
|
||||||
|
`Finished extracting CodeQL bundle to ${codeqlExtracted} (${extractionMs} ms).`,
|
||||||
|
);
|
||||||
|
|
||||||
logger.debug(`Finished extracting CodeQL bundle to ${codeqlExtracted}.`);
|
logger.debug("Cleaning up CodeQL bundle archive.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await del(codeqlPath, { force: true });
|
await del(codeqlPath, { force: true });
|
||||||
logger.debug("Deleted CodeQL bundle archive.");
|
logger.debug("Deleted CodeQL bundle archive.");
|
||||||
|
|
@ -624,13 +629,30 @@ export async function downloadCodeQL(
|
||||||
const toolcacheVersion = maybeCliVersion?.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
const toolcacheVersion = maybeCliVersion?.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)
|
||||||
? `${maybeCliVersion}-${bundleVersion}`
|
? `${maybeCliVersion}-${bundleVersion}`
|
||||||
: convertToSemVer(bundleVersion, logger);
|
: convertToSemVer(bundleVersion, logger);
|
||||||
|
|
||||||
|
logger.debug("Caching CodeQL bundle.");
|
||||||
|
const codeqlFolder = await toolcache.cacheDir(
|
||||||
|
codeqlExtracted,
|
||||||
|
"CodeQL",
|
||||||
|
toolcacheVersion,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Safety check to make sure that we don't delete the bundle we're about to use.
|
||||||
|
if (codeqlFolder !== codeqlExtracted) {
|
||||||
|
logger.debug("Cleaning up downloaded CodeQL bundle.");
|
||||||
|
try {
|
||||||
|
await del(codeqlPath, { force: true });
|
||||||
|
logger.debug("Deleted CodeQL bundle from temporary directory.");
|
||||||
|
} catch (e) {
|
||||||
|
logger.warning(
|
||||||
|
"Failed to delete CodeQL bundle from temporary directory.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
toolsVersion: maybeCliVersion ?? toolcacheVersion,
|
toolsVersion: maybeCliVersion ?? toolcacheVersion,
|
||||||
codeqlFolder: await toolcache.cacheDir(
|
codeqlFolder,
|
||||||
codeqlExtracted,
|
|
||||||
"CodeQL",
|
|
||||||
toolcacheVersion,
|
|
||||||
),
|
|
||||||
toolsDownloadDurationMs,
|
toolsDownloadDurationMs,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue