Write toolcache marker file

This commit is contained in:
Henry Mercer 2024-12-02 18:30:02 +00:00
parent 028cece17f
commit 0b2048550c
6 changed files with 59 additions and 29 deletions

22
lib/setup-codeql.js generated
View file

@ -417,16 +417,22 @@ const downloadCodeQL = async function (codeqlURL, maybeBundleVersion, maybeCliVe
toolsVersion: maybeCliVersion ?? "unknown",
};
}
logger.debug("Caching CodeQL bundle.");
const toolcacheStart = perf_hooks_1.performance.now();
const toolcachedBundlePath = await toolcache.cacheDir(extractedBundlePath, "CodeQL", toolcacheInfo.version);
logger.info(`Added CodeQL bundle to the tool cache (${(0, logging_1.formatDuration)(perf_hooks_1.performance.now() - toolcacheStart)}).`);
// Defensive check: we expect `cacheDir` to copy the bundle to a new location.
if (toolcachedBundlePath !== extractedBundlePath) {
await (0, util_1.cleanUpGlob)(extractedBundlePath, "CodeQL bundle from temporary directory", logger);
let codeqlFolder = extractedBundlePath;
if (extractToToolcache) {
(0, tools_download_1.writeToolcacheMarkerFile)(toolcacheInfo.path, logger);
}
else {
logger.debug("Caching CodeQL bundle.");
const toolcacheStart = perf_hooks_1.performance.now();
codeqlFolder = await toolcache.cacheDir(extractedBundlePath, "CodeQL", toolcacheInfo.version);
logger.info(`Added CodeQL bundle to the tool cache (${(0, logging_1.formatDuration)(perf_hooks_1.performance.now() - toolcacheStart)}).`);
// Defensive check: we expect `cacheDir` to copy the bundle to a new location.
if (codeqlFolder !== extractedBundlePath) {
await (0, util_1.cleanUpGlob)(extractedBundlePath, "CodeQL bundle from temporary directory", logger);
}
}
return {
codeqlFolder: toolcachedBundlePath,
codeqlFolder,
statusReport,
toolsVersion: maybeCliVersion ?? toolcacheInfo.version,
};