Skip to content

Commit 33206d2

Browse files
committed
Include the bundle version in the toolcache version number
This gives us an easy cache hit when requesting the same tools URL.
1 parent c2e39e0 commit 33206d2

6 files changed

Lines changed: 23 additions & 15 deletions

File tree

lib/codeql.test.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-codeql.js

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-codeql.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codeql.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ test("tries to cache an explicitly requested bundle with its CLI version number"
265265
false
266266
);
267267
t.assert(releaseApiMock.isDone(), "Releases API should have been called");
268-
t.assert(toolcache.find("CodeQL", "2.10.0"));
268+
t.assert(toolcache.find("CodeQL", "2.10.0-20200610"));
269269
t.deepEqual(result.toolsVersion, "0.0.0-20200610");
270270
});
271271
});

src/setup-codeql.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ export async function getCodeQLSource(
521521

522522
export async function downloadCodeQL(
523523
codeqlURL: string,
524-
cliVersion: string | undefined,
524+
maybeCliVersion: string | undefined,
525525
apiDetails: api.GitHubApiDetails,
526526
variant: util.GitHubVariant,
527527
tempDir: string,
@@ -564,15 +564,19 @@ export async function downloadCodeQL(
564564
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
565565

566566
const bundleVersion = getBundleVersionFromUrl(codeqlURL);
567-
// If we have a CLI version, use that. Otherwise, try to find the CLI version from the GitHub Releases
568-
const toolcacheVersion =
569-
cliVersion ||
567+
// Try to compute the CLI version for this bundle
568+
const cliVersion =
569+
maybeCliVersion ||
570570
(variant === util.GitHubVariant.DOTCOM &&
571571
(await tryFindCliVersionDotcomOnly(
572572
`codeql-bundle-${bundleVersion}`,
573573
logger
574-
))) ||
575-
convertToSemVer(bundleVersion, logger);
574+
)));
575+
// Include the bundle version in the toolcache version number so that if the user requests the
576+
// same URL again, we can get it from the cache without having to call any of the Releases API.
577+
const toolcacheVersion = cliVersion
578+
? `${cliVersion}-${bundleVersion}`
579+
: convertToSemVer(bundleVersion, logger);
576580
return await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion);
577581
}
578582

0 commit comments

Comments
 (0)