@@ -6,8 +6,10 @@ import * as glob from "@actions/glob";
66
77import { getTemporaryDirectory } from "./actions-util" ;
88import { getTotalCacheSize } from "./caching-utils" ;
9+ import { CodeQL } from "./codeql" ;
910import { Config } from "./config-utils" ;
1011import { EnvVar } from "./environment" ;
12+ import { Feature , Features } from "./feature-flags" ;
1113import { KnownLanguage , Language } from "./languages" ;
1214import { Logger } from "./logging" ;
1315import { getRequiredEnvParam } from "./util" ;
@@ -87,15 +89,17 @@ async function makeGlobber(patterns: string[]): Promise<glob.Globber> {
8789/**
8890 * Attempts to restore dependency caches for the languages being analyzed.
8991 *
92+ * @param codeql The CodeQL instance to use.
93+ * @param features Information about which FFs are enabled.
9094 * @param languages The languages being analyzed.
9195 * @param logger A logger to record some informational messages to.
92- * @param minimizeJavaJars Whether the Java extractor should rewrite downloaded JARs to minimize their size.
9396 * @returns A list of languages for which dependency caches were restored.
9497 */
9598export async function downloadDependencyCaches (
99+ codeql : CodeQL ,
100+ features : Features ,
96101 languages : Language [ ] ,
97102 logger : Logger ,
98- minimizeJavaJars : boolean ,
99103) : Promise < Language [ ] > {
100104 const restoredCaches : Language [ ] = [ ] ;
101105
@@ -120,9 +124,9 @@ export async function downloadDependencyCaches(
120124 continue ;
121125 }
122126
123- const primaryKey = await cacheKey ( language , cacheConfig , minimizeJavaJars ) ;
127+ const primaryKey = await cacheKey ( codeql , features , language , cacheConfig ) ;
124128 const restoreKeys : string [ ] = [
125- await cachePrefix ( language , minimizeJavaJars ) ,
129+ await cachePrefix ( codeql , features , language ) ,
126130 ] ;
127131
128132 logger . info (
@@ -151,14 +155,16 @@ export async function downloadDependencyCaches(
151155/**
152156 * Attempts to store caches for the languages that were analyzed.
153157 *
158+ * @param codeql The CodeQL instance to use.
159+ * @param features Information about which FFs are enabled.
154160 * @param config The configuration for this workflow.
155161 * @param logger A logger to record some informational messages to.
156- * @param minimizeJavaJars Whether the Java extractor should rewrite downloaded JARs to minimize their size.
157162 */
158163export async function uploadDependencyCaches (
164+ codeql : CodeQL ,
165+ features : Features ,
159166 config : Config ,
160167 logger : Logger ,
161- minimizeJavaJars : boolean ,
162168) : Promise < void > {
163169 for ( const language of config . languages ) {
164170 const cacheConfig = getDefaultCacheConfig ( ) [ language ] ;
@@ -201,7 +207,7 @@ export async function uploadDependencyCaches(
201207 continue ;
202208 }
203209
204- const key = await cacheKey ( language , cacheConfig , minimizeJavaJars ) ;
210+ const key = await cacheKey ( codeql , features , language , cacheConfig ) ;
205211
206212 logger . info (
207213 `Uploading cache of size ${ size } for ${ language } with key ${ key } ...` ,
@@ -229,31 +235,35 @@ export async function uploadDependencyCaches(
229235/**
230236 * Computes a cache key for the specified language.
231237 *
238+ * @param codeql The CodeQL instance to use.
239+ * @param features Information about which FFs are enabled.
232240 * @param language The language being analyzed.
233241 * @param cacheConfig The cache configuration for the language.
234- * @param minimizeJavaJars Whether the Java extractor should rewrite downloaded JARs to minimize their size.
235242 * @returns A cache key capturing information about the project(s) being analyzed in the specified language.
236243 */
237244async function cacheKey (
245+ codeql : CodeQL ,
246+ features : Features ,
238247 language : Language ,
239248 cacheConfig : CacheConfig ,
240- minimizeJavaJars : boolean = false ,
241249) : Promise < string > {
242250 const hash = await glob . hashFiles ( cacheConfig . hash . join ( "\n" ) ) ;
243- return `${ await cachePrefix ( language , minimizeJavaJars ) } ${ hash } ` ;
251+ return `${ await cachePrefix ( codeql , features , language ) } ${ hash } ` ;
244252}
245253
246254/**
247255 * Constructs a prefix for the cache key, comprised of a CodeQL-specific prefix, a version number that
248256 * can be changed to invalidate old caches, the runner's operating system, and the specified language name.
249257 *
258+ * @param codeql The CodeQL instance to use.
259+ * @param features Information about which FFs are enabled.
250260 * @param language The language being analyzed.
251- * @param minimizeJavaJars Whether the Java extractor should rewrite downloaded JARs to minimize their size.
252261 * @returns The prefix that identifies what a cache is for.
253262 */
254263async function cachePrefix (
264+ codeql : CodeQL ,
265+ features : Features ,
255266 language : Language ,
256- minimizeJavaJars : boolean ,
257267) : Promise < string > {
258268 const runnerOs = getRequiredEnvParam ( "RUNNER_OS" ) ;
259269 const customPrefix = process . env [ EnvVar . DEPENDENCY_CACHING_PREFIX ] ;
@@ -264,6 +274,10 @@ async function cachePrefix(
264274 }
265275
266276 // To ensure a safe rollout of JAR minimization, we change the key when the feature is enabled.
277+ const minimizeJavaJars = await features . getValue (
278+ Feature . JavaMinimizeDependencyJars ,
279+ codeql ,
280+ ) ;
267281 if ( language === KnownLanguage . java && minimizeJavaJars ) {
268282 prefix = `minify-${ prefix } ` ;
269283 }
0 commit comments