@@ -480,26 +480,37 @@ export async function getCacheRestoreKeyPrefix(
480480 codeQlVersion : string ,
481481) : Promise < string > {
482482 const languages = [ ...config . languages ] . sort ( ) . join ( "_" ) ;
483-
484- const cacheKeyComponents = {
485- automationID : await getAutomationID ( ) ,
486- // Add more components here as needed in the future
487- } ;
488- const componentsHash = createCacheKeyHash ( cacheKeyComponents ) ;
483+ const workflowPrefix = await getCacheWorkflowKeyPrefix ( ) ;
489484
490485 // For a cached overlay-base database to be considered compatible for overlay
491486 // analysis, all components in the cache restore key must match:
492487 //
493- // CACHE_PREFIX: distinguishes overlay-base databases from other cache objects
494- // CACHE_VERSION: cache format version
495- // componentsHash: hash of additional components (see above for details)
488+ // workflowPrefix contains components that depend only on the workflow:
489+ // CACHE_PREFIX: distinguishes overlay-base databases from other cache objects
490+ // CACHE_VERSION: cache format version
491+ // componentsHash: hash of additional components (see above for details)
496492 // languages: the languages included in the overlay-base database
497493 // codeQlVersion: CodeQL bundle version
498494 //
499495 // Technically we can also include languages and codeQlVersion in the
500496 // componentsHash, but including them explicitly in the cache key makes it
501497 // easier to debug and understand the cache key structure.
502- return `${ CACHE_PREFIX } -${ CACHE_VERSION } -${ componentsHash } -${ languages } -${ codeQlVersion } -` ;
498+ return `${ workflowPrefix } ${ languages } -${ codeQlVersion } -` ;
499+ }
500+
501+ /**
502+ * Computes the cache key prefix that depends only on the workflow.
503+ *
504+ * @returns A promise that resolves to the common cache key prefix in the format
505+ * `${CACHE_PREFIX}-${CACHE_VERSION}-${componentsHash}-`
506+ */
507+ export async function getCacheWorkflowKeyPrefix ( ) : Promise < string > {
508+ const cacheKeyComponents = {
509+ automationID : await getAutomationID ( ) ,
510+ // Add more components here as needed in the future
511+ } ;
512+ const componentsHash = createCacheKeyHash ( cacheKeyComponents ) ;
513+ return `${ CACHE_PREFIX } -${ CACHE_VERSION } -${ componentsHash } -` ;
503514}
504515
505516/**
0 commit comments