@@ -8,11 +8,7 @@ import {
88 getWorkflowRunAttempt ,
99 getWorkflowRunID ,
1010} from "../actions-util" ;
11- import {
12- type ActionsCacheItem ,
13- getAutomationID ,
14- listActionsCaches ,
15- } from "../api-client" ;
11+ import { getAutomationID , listActionsCaches } from "../api-client" ;
1612import { createCacheKeyHash } from "../caching-utils" ;
1713import { type CodeQL } from "../codeql" ;
1814import { type Config } from "../config-utils" ;
@@ -52,12 +48,6 @@ const OVERLAY_BASE_DATABASE_MAX_UPLOAD_SIZE_BYTES =
5248const CACHE_VERSION = 1 ;
5349const CACHE_PREFIX = "codeql-overlay-base-database" ;
5450
55- // The Actions cache evicts entries that have not been accessed in the past 7
56- // days. We conservatively set a limit of 6 days to avoid using a cached base DB
57- // that may be evicted before we can download it.
58- const CACHE_ENTRY_MAX_AGE_DAYS = 6 ;
59- const CACHE_ENTRY_MAX_AGE_MS = CACHE_ENTRY_MAX_AGE_DAYS * 24 * 60 * 60 * 1000 ;
60-
6151// The purpose of this ten-minute limit is to guard against the possibility
6252// that the cache service is unresponsive, which would otherwise cause the
6353// entire action to hang. Normally we expect cache operations to complete
@@ -445,39 +435,6 @@ async function getCacheKeyPrefixBase(
445435 return `${ CACHE_PREFIX } -${ CACHE_VERSION } -${ componentsHash } -${ languagesComponent } -` ;
446436}
447437
448- /**
449- * Lists overlay-base database cache entries with the given key prefix, ignoring entries that are
450- * old enough that they may be evicted by the Actions cache before we attempt to download them.
451- */
452- async function listRecentOverlayBaseDatabaseCaches (
453- cacheKeyPrefix : string ,
454- logger : Logger ,
455- ) : Promise < ActionsCacheItem [ ] > {
456- const allCaches = await listActionsCaches ( cacheKeyPrefix ) ;
457-
458- if ( allCaches . length === 0 ) {
459- logger . info ( "No overlay-base databases found in Actions cache." ) ;
460- return [ ] ;
461- }
462-
463- const cutoffMs = Date . now ( ) - CACHE_ENTRY_MAX_AGE_MS ;
464- const recentCaches = allCaches . filter ( ( cache ) => {
465- if ( ! cache . last_accessed_at ) return true ;
466- const lastAccessedMs = Date . parse ( cache . last_accessed_at ) ;
467- return Number . isNaN ( lastAccessedMs ) || lastAccessedMs >= cutoffMs ;
468- } ) ;
469- const numTooOldDatabases = allCaches . length - recentCaches . length ;
470- const tooOldSuffix =
471- numTooOldDatabases > 0
472- ? ` (ignoring ${ numTooOldDatabases } that may be evicted soon)`
473- : "" ;
474- logger . info (
475- `Found ${ allCaches . length } overlay-base ${ allCaches . length === 1 ? "database" : "databases" } in the Actions cache${ tooOldSuffix } .` ,
476- ) ;
477-
478- return recentCaches ;
479- }
480-
481438/**
482439 * Searches the GitHub Actions cache for overlay-base databases matching the given languages, and
483440 * returns all stable CodeQL versions found across matching cache entries.
@@ -491,7 +448,7 @@ export async function getCodeQlVersionsForOverlayBaseDatabases(
491448) : Promise < string [ ] | undefined > {
492449 const languages = rawLanguages . map ( parseBuiltInLanguage ) ;
493450 if ( languages . includes ( undefined ) ) {
494- logger . info (
451+ logger . warning (
495452 "One or more provided languages are not recognized as built-in languages. " +
496453 "Skipping searching for overlay-base databases in cache." ,
497454 ) ;
@@ -506,19 +463,22 @@ export async function getCodeQlVersionsForOverlayBaseDatabases(
506463 `prefix ${ cacheKeyPrefix } ` ,
507464 ) ;
508465
509- const caches = await listRecentOverlayBaseDatabaseCaches (
510- cacheKeyPrefix ,
511- logger ,
512- ) ;
466+ const caches = await listActionsCaches ( cacheKeyPrefix ) ;
513467
514468 if ( caches . length === 0 ) {
469+ logger . info ( "No overlay-base databases found in Actions cache." ) ;
515470 return [ ] ;
516471 }
517472
473+ logger . info (
474+ `Found ${ caches . length } overlay-base ` +
475+ `${ caches . length === 1 ? "database" : "databases" } in the Actions cache.` ,
476+ ) ;
477+
518478 // Parse CodeQL versions from cache keys, matching only stable releases.
519479 //
520- // After the prefix, the remaining key format starts with `${codeQlVersion}-`. Nightlies have a
521- // suffix like `+202604201548` that will prevent a match.
480+ // After the prefix, the remaining key format starts with `${codeQlVersion}-`. Nightlies will have
481+ // a suffix like `+202604201548` that will break the match.
522482 //
523483 // Caveat: this relies on the fact that we haven't released any CodeQL bundles with the
524484 // `x.y.z-<pre-release>` semver format which does not interact well with the current overlay base
@@ -546,7 +506,7 @@ export async function getCodeQlVersionsForOverlayBaseDatabases(
546506 const versions = [ ...versionSet ] . sort ( semver . rcompare ) ;
547507
548508 logger . info (
549- `Found overlay-base databases for the following CodeQL versions in the Actions cache: ${ versions . join ( ", " ) } ` ,
509+ `Found overlay databases for the following CodeQL versions in the Actions cache: ${ versions . join ( ", " ) } ` ,
550510 ) ;
551511
552512 return versions ;
0 commit comments