@@ -7,8 +7,10 @@ import * as glob from "@actions/glob";
77import { getTemporaryDirectory } from "./actions-util" ;
88import { listActionsCaches } from "./api-client" ;
99import { getTotalCacheSize } from "./caching-utils" ;
10+ import { CodeQL } from "./codeql" ;
1011import { Config } from "./config-utils" ;
1112import { EnvVar } from "./environment" ;
13+ import { Feature , Features } from "./feature-flags" ;
1214import { KnownLanguage , Language } from "./languages" ;
1315import { Logger } from "./logging" ;
1416import { getErrorMessage , getRequiredEnvParam } from "./util" ;
@@ -110,15 +112,18 @@ export type DependencyCacheRestoreStatusReport = DependencyCacheRestoreStatus[];
110112/**
111113 * Attempts to restore dependency caches for the languages being analyzed.
112114 *
115+ * @param codeql The CodeQL instance to use.
116+ * @param features Information about which FFs are enabled.
113117 * @param languages The languages being analyzed.
114118 * @param logger A logger to record some informational messages to.
115- * @param minimizeJavaJars Whether the Java extractor should rewrite downloaded JARs to minimize their size.
119+ *
116120 * @returns An array of `DependencyCacheRestoreStatus` objects for each analysed language with a caching configuration.
117121 */
118122export async function downloadDependencyCaches (
123+ codeql : CodeQL ,
124+ features : Features ,
119125 languages : Language [ ] ,
120126 logger : Logger ,
121- minimizeJavaJars : boolean ,
122127) : Promise < DependencyCacheRestoreStatusReport > {
123128 const status : DependencyCacheRestoreStatusReport = [ ] ;
124129
@@ -144,9 +149,9 @@ export async function downloadDependencyCaches(
144149 continue ;
145150 }
146151
147- const primaryKey = await cacheKey ( language , cacheConfig , minimizeJavaJars ) ;
152+ const primaryKey = await cacheKey ( codeql , features , language , cacheConfig ) ;
148153 const restoreKeys : string [ ] = [
149- await cachePrefix ( language , minimizeJavaJars ) ,
154+ await cachePrefix ( codeql , features , language ) ,
150155 ] ;
151156
152157 logger . info (
@@ -203,16 +208,18 @@ export type DependencyCacheUploadStatusReport = DependencyCacheUploadStatus[];
203208/**
204209 * Attempts to store caches for the languages that were analyzed.
205210 *
211+ * @param codeql The CodeQL instance to use.
212+ * @param features Information about which FFs are enabled.
206213 * @param config The configuration for this workflow.
207214 * @param logger A logger to record some informational messages to.
208- * @param minimizeJavaJars Whether the Java extractor should rewrite downloaded JARs to minimize their size.
209215 *
210216 * @returns An array of `DependencyCacheUploadStatus` objects for each analysed language with a caching configuration.
211217 */
212218export async function uploadDependencyCaches (
219+ codeql : CodeQL ,
220+ features : Features ,
213221 config : Config ,
214222 logger : Logger ,
215- minimizeJavaJars : boolean ,
216223) : Promise < DependencyCacheUploadStatusReport > {
217224 const status : DependencyCacheUploadStatusReport = [ ] ;
218225 for ( const language of config . languages ) {
@@ -258,7 +265,7 @@ export async function uploadDependencyCaches(
258265 continue ;
259266 }
260267
261- const key = await cacheKey ( language , cacheConfig , minimizeJavaJars ) ;
268+ const key = await cacheKey ( codeql , features , language , cacheConfig ) ;
262269
263270 logger . info (
264271 `Uploading cache of size ${ size } for ${ language } with key ${ key } ...` ,
@@ -299,31 +306,35 @@ export async function uploadDependencyCaches(
299306/**
300307 * Computes a cache key for the specified language.
301308 *
309+ * @param codeql The CodeQL instance to use.
310+ * @param features Information about which FFs are enabled.
302311 * @param language The language being analyzed.
303312 * @param cacheConfig The cache configuration for the language.
304- * @param minimizeJavaJars Whether the Java extractor should rewrite downloaded JARs to minimize their size.
305313 * @returns A cache key capturing information about the project(s) being analyzed in the specified language.
306314 */
307315async function cacheKey (
316+ codeql : CodeQL ,
317+ features : Features ,
308318 language : Language ,
309319 cacheConfig : CacheConfig ,
310- minimizeJavaJars : boolean = false ,
311320) : Promise < string > {
312321 const hash = await glob . hashFiles ( cacheConfig . hash . join ( "\n" ) ) ;
313- return `${ await cachePrefix ( language , minimizeJavaJars ) } ${ hash } ` ;
322+ return `${ await cachePrefix ( codeql , features , language ) } ${ hash } ` ;
314323}
315324
316325/**
317326 * Constructs a prefix for the cache key, comprised of a CodeQL-specific prefix, a version number that
318327 * can be changed to invalidate old caches, the runner's operating system, and the specified language name.
319328 *
329+ * @param codeql The CodeQL instance to use.
330+ * @param features Information about which FFs are enabled.
320331 * @param language The language being analyzed.
321- * @param minimizeJavaJars Whether the Java extractor should rewrite downloaded JARs to minimize their size.
322332 * @returns The prefix that identifies what a cache is for.
323333 */
324334async function cachePrefix (
335+ codeql : CodeQL ,
336+ features : Features ,
325337 language : Language ,
326- minimizeJavaJars : boolean ,
327338) : Promise < string > {
328339 const runnerOs = getRequiredEnvParam ( "RUNNER_OS" ) ;
329340 const customPrefix = process . env [ EnvVar . DEPENDENCY_CACHING_PREFIX ] ;
@@ -334,6 +345,10 @@ async function cachePrefix(
334345 }
335346
336347 // To ensure a safe rollout of JAR minimization, we change the key when the feature is enabled.
348+ const minimizeJavaJars = await features . getValue (
349+ Feature . JavaMinimizeDependencyJars ,
350+ codeql ,
351+ ) ;
337352 if ( language === KnownLanguage . java && minimizeJavaJars ) {
338353 prefix = `minify-${ prefix } ` ;
339354 }
0 commit comments