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:
parent
c2e39e078f
commit
33206d299e
6 changed files with 23 additions and 15 deletions
|
|
@ -265,7 +265,7 @@ test("tries to cache an explicitly requested bundle with its CLI version number"
|
|||
false
|
||||
);
|
||||
t.assert(releaseApiMock.isDone(), "Releases API should have been called");
|
||||
t.assert(toolcache.find("CodeQL", "2.10.0"));
|
||||
t.assert(toolcache.find("CodeQL", "2.10.0-20200610"));
|
||||
t.deepEqual(result.toolsVersion, "0.0.0-20200610");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -521,7 +521,7 @@ export async function getCodeQLSource(
|
|||
|
||||
export async function downloadCodeQL(
|
||||
codeqlURL: string,
|
||||
cliVersion: string | undefined,
|
||||
maybeCliVersion: string | undefined,
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
variant: util.GitHubVariant,
|
||||
tempDir: string,
|
||||
|
|
@ -564,15 +564,19 @@ export async function downloadCodeQL(
|
|||
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);
|
||||
)));
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue