mirror of
https://github.com/github/codeql-action.git
synced 2026-10-30 17:39:50 +00:00
Include the bundle version in the toolcache version number
This gives us an easy cache hit when requesting the same tools URL.
This commit is contained in:
14
lib/setup-codeql.js
generated
14
lib/setup-codeql.js
generated
@@ -397,7 +397,7 @@ async function getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, a
|
||||
};
|
||||
}
|
||||
exports.getCodeQLSource = getCodeQLSource;
|
||||
async function downloadCodeQL(codeqlURL, cliVersion, apiDetails, variant, tempDir, logger) {
|
||||
async function downloadCodeQL(codeqlURL, maybeCliVersion, apiDetails, variant, tempDir, logger) {
|
||||
const parsedCodeQLURL = new URL(codeqlURL);
|
||||
const searchParams = new URLSearchParams(parsedCodeQLURL.search);
|
||||
const headers = {
|
||||
@@ -424,11 +424,15 @@ async function downloadCodeQL(codeqlURL, cliVersion, apiDetails, variant, tempDi
|
||||
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||
const bundleVersion = getBundleVersionFromUrl(codeqlURL);
|
||||
// If we have a CLI version, use that. Otherwise, try to find the CLI version from the GitHub Releases
|
||||
const toolcacheVersion = cliVersion ||
|
||||
// Try to compute the CLI version for this bundle
|
||||
const cliVersion = maybeCliVersion ||
|
||||
(variant === util.GitHubVariant.DOTCOM &&
|
||||
(await tryFindCliVersionDotcomOnly(`codeql-bundle-${bundleVersion}`, logger))) ||
|
||||
convertToSemVer(bundleVersion, logger);
|
||||
(await tryFindCliVersionDotcomOnly(`codeql-bundle-${bundleVersion}`, logger)));
|
||||
// Include the bundle version in the toolcache version number so that if the user requests the
|
||||
// same URL again, we can get it from the cache without having to call any of the Releases API.
|
||||
const toolcacheVersion = cliVersion
|
||||
? `${cliVersion}-${bundleVersion}`
|
||||
: convertToSemVer(bundleVersion, logger);
|
||||
return await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion);
|
||||
}
|
||||
exports.downloadCodeQL = downloadCodeQL;
|
||||
|
||||
Reference in New Issue
Block a user