Allow using a x.y.z-yyyymmdd toolcache version for CLI x.y.z.

This commit is contained in:
Henry Mercer 2023-01-12 15:39:26 +00:00
parent e8c12e1f7d
commit 648838c4a0
6 changed files with 100 additions and 17 deletions

25
lib/codeql.test.js generated
View file

@ -147,14 +147,31 @@ async function installIntoToolcache({ apiDetails = sampleApiDetails, cliVersion,
t.deepEqual(result.toolsVersion, "0.0.0-20200610");
});
});
for (const isCached of [true, false]) {
(0, ava_1.default)(`uses default version on Dotcom when default version bundle is ${isCached ? "" : "not "}cached`, async (t) => {
for (const { isCached, tagName, toolcacheCliVersion } of [
{
isCached: true,
tagName: "codeql-bundle-20230101",
toolcacheCliVersion: SAMPLE_DEFAULT_CLI_VERSION.cliVersion,
},
{
isCached: true,
// By leaving toolcacheCliVersion undefined, the bundle will be installed
// into the toolcache as `${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}-20230101`.
// This lets us test that `x.y.z-yyyymmdd` toolcache versions are used if an
// `x.y.z` version isn't in the toolcache.
tagName: `codeql-bundle-${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}-20230101`,
},
{
isCached: false,
tagName: "codeql-bundle-20230101",
},
]) {
(0, ava_1.default)(`uses default version on Dotcom when default version bundle ${tagName} is ${isCached ? "" : "not "}cached`, async (t) => {
await util.withTmpDir(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
const tagName = `codeql-bundle-20230101`;
if (isCached) {
await installIntoToolcache({
cliVersion: SAMPLE_DEFAULT_CLI_VERSION.cliVersion,
cliVersion: toolcacheCliVersion,
tagName,
isPinned: true,
tmpDir,