Skip to content

Commit

Permalink
Merge pull request #1496 from github/henrymercer/no-cache-nightlies
Browse files Browse the repository at this point in the history
Increase strictness of tool caching threshold to avoid caching nightlies
  • Loading branch information
Henry Mercer authored and GitHub committed Jan 20, 2023
2 parents 6456115 + 54f4ea7 commit 421a1b3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lib/codeql.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.test.js.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions lib/setup-codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/setup-codeql.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ const EXPLICITLY_REQUESTED_BUNDLE_TEST_CASES = [
cliVersion: "2.10.0-pre",
expectedToolcacheVersion: "0.0.0-20200610",
},
{
cliVersion: "2.10.0+202006100101",
expectedToolcacheVersion: "0.0.0-20200610",
},
];

for (const {
Expand Down
10 changes: 6 additions & 4 deletions src/setup-codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,13 @@ export async function downloadCodeQL(
// if the user requests the same URL again, we can get it from the cache without having to call
// any of the Releases API.
//
// Special case: If the CLI version is a pre-release, then cache the bundle as
// `0.0.0-<bundleVersion>` to avoid the bundle being interpreted as containing a stable CLI
// release.
// Special case: If the CLI version is a pre-release or contains build metadata, then cache the
// bundle as `0.0.0-<bundleVersion>` to avoid the bundle being interpreted as containing a stable
// CLI release. In principle, it should be enough to just check that the CLI version isn't a
// pre-release, but the version numbers of CodeQL nightlies have the format `x.y.z+<timestamp>`,
// and we don't want these nightlies to override stable CLI versions in the toolcache.
const toolcacheVersion =
cliVersion && !cliVersion.includes("-")
cliVersion && cliVersion.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)
? `${cliVersion}-${bundleVersion}`
: convertToSemVer(bundleVersion, logger);
return {
Expand Down

0 comments on commit 421a1b3

Please sign in to comment.