Skip to content

Commit 5026833

Browse files
committed
Document exclusion of nightlies
1 parent 201ddc2 commit 5026833

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

src/overlay/caching.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,30 @@ test.serial(
390390
t.deepEqual(result, ["2.25.0"]);
391391
},
392392
);
393+
394+
test.serial(
395+
"getCodeQlVersionsForOverlayBaseDatabases ignores nightly versions with build metadata",
396+
async (t) => {
397+
const logger = getRunnerLogger(true);
398+
399+
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
400+
sinon.stub(apiClient, "listActionsCaches").resolves([
401+
{
402+
key: "codeql-overlay-base-database-1-c5666c509a2d9895-python-2.25.0-abc123-1-1",
403+
},
404+
{
405+
// Nightly release with semver build metadata; should be ignored.
406+
key: "codeql-overlay-base-database-1-c5666c509a2d9895-python-2.26.0+202604211234-def456-2-1",
407+
},
408+
{
409+
key: "codeql-overlay-base-database-1-c5666c509a2d9895-python-2.24.0-ghi789-3-1",
410+
},
411+
]);
412+
413+
const result = await getCodeQlVersionsForOverlayBaseDatabases(
414+
["python"],
415+
logger,
416+
);
417+
t.deepEqual(result, ["2.25.0", "2.24.0"]);
418+
},
419+
);

src/overlay/caching.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,9 @@ async function getCacheKeyPrefixBase(
437437

438438
/**
439439
* Searches the GitHub Actions cache for overlay-base databases matching the given languages, and
440-
* returns all CodeQL versions found across matching cache entries.
440+
* returns all stable CodeQL versions found across matching cache entries.
441441
*
442-
* @returns Unique CodeQL versions found in cached overlay-base databases, sorted from latest to
442+
* @returns Unique stable CodeQL versions found in cached overlay-base databases, sorted from latest to
443443
* earliest, or undefined if one of the languages is not a built-in language.
444444
*/
445445
export async function getCodeQlVersionsForOverlayBaseDatabases(
@@ -475,9 +475,14 @@ export async function getCodeQlVersionsForOverlayBaseDatabases(
475475
`${caches.length === 1 ? "database" : "databases"} in the Actions cache.`,
476476
);
477477

478-
// Parse CodeQL versions from cache keys.
479-
// After the prefix, the remaining key format starts with
480-
// `${codeQlVersion}-`.
478+
// Parse CodeQL versions from cache keys, matching only stable releases.
479+
//
480+
// After the prefix, the remaining key format starts with `${codeQlVersion}-`. Nightlies will have
481+
// a suffix like `+202604201548` that will break the match.
482+
//
483+
// Caveat: this relies on the fact that we haven't released any CodeQL bundles with the
484+
// `x.y.z-<pre-release>` semver format which does not interact well with the current overlay base
485+
// DB cache key format.
481486
const versionRegex = /^([\d.]+)-/;
482487
const versionSet = new Set<string>();
483488

0 commit comments

Comments
 (0)