mirror of
https://github.com/github/codeql-action.git
synced 2026-04-26 08:48:46 +00:00
Merge pull request #3352 from github/nickrolfe/jar-min-ff-cleanup
Clean up `JavaMinimizeDependencyJars` feature flag
This commit is contained in:
Generated
-5
@@ -120070,11 +120070,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
Generated
+2
-19
@@ -88710,11 +88710,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
@@ -91278,15 +91273,7 @@ async function getFeaturePrefix(codeql, features, language) {
|
||||
enabledFeatures.push(feature);
|
||||
}
|
||||
};
|
||||
if (language === "java" /* java */) {
|
||||
const minimizeJavaJars = await features.getValue(
|
||||
"java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */,
|
||||
codeql
|
||||
);
|
||||
if (minimizeJavaJars) {
|
||||
return "minify-";
|
||||
}
|
||||
} else if (language === "csharp" /* csharp */) {
|
||||
if (language === "csharp" /* csharp */) {
|
||||
await addFeatureIfEnabled("csharp_new_cache_key" /* CsharpNewCacheKey */);
|
||||
await addFeatureIfEnabled("csharp_cache_bmn" /* CsharpCacheBuildModeNone */);
|
||||
}
|
||||
@@ -91303,11 +91290,7 @@ async function cachePrefix2(codeql, features, language) {
|
||||
prefix = `${prefix}-${customPrefix}`;
|
||||
}
|
||||
const featurePrefix = await getFeaturePrefix(codeql, features, language);
|
||||
if (featurePrefix === "minify-") {
|
||||
return `${featurePrefix}${prefix}-${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
} else {
|
||||
return `${prefix}-${featurePrefix}${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
}
|
||||
return `${prefix}-${featurePrefix}${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
}
|
||||
var internal = {
|
||||
makePatternCheck
|
||||
|
||||
Generated
-5
@@ -84011,11 +84011,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
Generated
-5
@@ -123451,11 +123451,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
Generated
+13
-20
@@ -81567,6 +81567,11 @@ var require_follow_redirects = __commonJS({
|
||||
});
|
||||
|
||||
// src/init-action.ts
|
||||
var init_action_exports = {};
|
||||
__export(init_action_exports, {
|
||||
CODEQL_VERSION_JAR_MINIMIZATION: () => CODEQL_VERSION_JAR_MINIMIZATION
|
||||
});
|
||||
module.exports = __toCommonJS(init_action_exports);
|
||||
var fs14 = __toESM(require("fs"));
|
||||
var path15 = __toESM(require("path"));
|
||||
var core13 = __toESM(require_core());
|
||||
@@ -86124,11 +86129,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
@@ -87458,15 +87458,7 @@ async function getFeaturePrefix(codeql, features, language) {
|
||||
enabledFeatures.push(feature);
|
||||
}
|
||||
};
|
||||
if (language === "java" /* java */) {
|
||||
const minimizeJavaJars = await features.getValue(
|
||||
"java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */,
|
||||
codeql
|
||||
);
|
||||
if (minimizeJavaJars) {
|
||||
return "minify-";
|
||||
}
|
||||
} else if (language === "csharp" /* csharp */) {
|
||||
if (language === "csharp" /* csharp */) {
|
||||
await addFeatureIfEnabled("csharp_new_cache_key" /* CsharpNewCacheKey */);
|
||||
await addFeatureIfEnabled("csharp_cache_bmn" /* CsharpCacheBuildModeNone */);
|
||||
}
|
||||
@@ -87483,11 +87475,7 @@ async function cachePrefix2(codeql, features, language) {
|
||||
prefix = `${prefix}-${customPrefix}`;
|
||||
}
|
||||
const featurePrefix = await getFeaturePrefix(codeql, features, language);
|
||||
if (featurePrefix === "minify-") {
|
||||
return `${featurePrefix}${prefix}-${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
} else {
|
||||
return `${prefix}-${featurePrefix}${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
}
|
||||
return `${prefix}-${featurePrefix}${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
}
|
||||
var internal = {
|
||||
makePatternCheck
|
||||
@@ -89891,6 +89879,7 @@ var internal2 = {
|
||||
};
|
||||
|
||||
// src/init-action.ts
|
||||
var CODEQL_VERSION_JAR_MINIMIZATION = "2.23.0";
|
||||
async function sendStartingStatusReport(startedAt, config, logger) {
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"init" /* Init */,
|
||||
@@ -90281,7 +90270,7 @@ exec ${goBinaryPath} "$@"`
|
||||
logger.debug(
|
||||
`${"CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */} is already set to '${process.env["CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */]}', so the Action will not override it.`
|
||||
);
|
||||
} else if (await features.getValue("java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */, codeql) && config.dependencyCachingEnabled && config.buildMode === "none" /* None */ && config.languages.includes("java" /* java */)) {
|
||||
} else if (await codeQlVersionAtLeast(codeql, CODEQL_VERSION_JAR_MINIMIZATION) && config.dependencyCachingEnabled && config.buildMode === "none" /* None */ && config.languages.includes("java" /* java */)) {
|
||||
core13.exportVariable(
|
||||
"CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */,
|
||||
"true"
|
||||
@@ -90402,6 +90391,10 @@ async function runWrapper() {
|
||||
await checkForTimeout();
|
||||
}
|
||||
void runWrapper();
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
CODEQL_VERSION_JAR_MINIMIZATION
|
||||
});
|
||||
/*! Bundled license information:
|
||||
|
||||
undici/lib/fetch/body.js:
|
||||
|
||||
Generated
-5
@@ -84002,11 +84002,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
Generated
-5
@@ -83914,11 +83914,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
Generated
-5
@@ -119476,11 +119476,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
Generated
-5
@@ -100067,11 +100067,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
Generated
-5
@@ -87067,11 +87067,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
Generated
-5
@@ -119642,11 +119642,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
Generated
-5
@@ -86864,11 +86864,6 @@ var featureConfig = {
|
||||
legacyApi: true,
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["java_minimize_dependency_jars" /* JavaMinimizeDependencyJars */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0"
|
||||
},
|
||||
["overlay_analysis" /* OverlayAnalysis */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
@@ -603,28 +603,6 @@ test("getFeaturePrefix - returns empty string if no features are enabled", async
|
||||
}
|
||||
});
|
||||
|
||||
test("getFeaturePrefix - Java - returns 'minify-' if JavaMinimizeDependencyJars is enabled", async (t) => {
|
||||
const codeql = createStubCodeQL({});
|
||||
const features = createFeatures([Feature.JavaMinimizeDependencyJars]);
|
||||
|
||||
const result = await getFeaturePrefix(codeql, features, KnownLanguage.java);
|
||||
t.deepEqual(result, "minify-");
|
||||
});
|
||||
|
||||
test("getFeaturePrefix - non-Java - returns '' if JavaMinimizeDependencyJars is enabled", async (t) => {
|
||||
const codeql = createStubCodeQL({});
|
||||
const features = createFeatures([Feature.JavaMinimizeDependencyJars]);
|
||||
|
||||
for (const knownLanguage of Object.values(KnownLanguage)) {
|
||||
// Skip Java since we expect a result for it, which is tested in the previous test.
|
||||
if (knownLanguage === KnownLanguage.java) {
|
||||
continue;
|
||||
}
|
||||
const result = await getFeaturePrefix(codeql, features, knownLanguage);
|
||||
t.deepEqual(result, "", `Expected no feature prefix for ${knownLanguage}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("getFeaturePrefix - C# - returns prefix if CsharpNewCacheKey is enabled", async (t) => {
|
||||
const codeql = createStubCodeQL({});
|
||||
const features = createFeatures([Feature.CsharpNewCacheKey]);
|
||||
|
||||
@@ -541,18 +541,7 @@ export async function getFeaturePrefix(
|
||||
}
|
||||
};
|
||||
|
||||
if (language === KnownLanguage.java) {
|
||||
// To ensure a safe rollout of JAR minimization, we change the key when the feature is enabled.
|
||||
const minimizeJavaJars = await features.getValue(
|
||||
Feature.JavaMinimizeDependencyJars,
|
||||
codeql,
|
||||
);
|
||||
|
||||
// To maintain backwards compatibility with this, we return "minify-" instead of a hash.
|
||||
if (minimizeJavaJars) {
|
||||
return "minify-";
|
||||
}
|
||||
} else if (language === KnownLanguage.csharp) {
|
||||
if (language === KnownLanguage.csharp) {
|
||||
await addFeatureIfEnabled(Feature.CsharpNewCacheKey);
|
||||
await addFeatureIfEnabled(Feature.CsharpCacheBuildModeNone);
|
||||
}
|
||||
@@ -593,14 +582,8 @@ async function cachePrefix(
|
||||
// experimental features that affect the cache contents.
|
||||
const featurePrefix = await getFeaturePrefix(codeql, features, language);
|
||||
|
||||
// Assemble the cache key. For backwards compatibility with the JAR minification experiment's existing
|
||||
// feature prefix usage, we add that feature prefix at the start. Other feature prefixes are inserted
|
||||
// after the general CodeQL dependency cache prefix.
|
||||
if (featurePrefix === "minify-") {
|
||||
return `${featurePrefix}${prefix}-${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
} else {
|
||||
return `${prefix}-${featurePrefix}${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
}
|
||||
// Assemble the cache key.
|
||||
return `${prefix}-${featurePrefix}${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||
}
|
||||
|
||||
/** Represents information about our overall cache usage for CodeQL dependency caches. */
|
||||
|
||||
@@ -53,7 +53,6 @@ export enum Feature {
|
||||
DisableJavaBuildlessEnabled = "disable_java_buildless_enabled",
|
||||
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
||||
ExportDiagnosticsEnabled = "export_diagnostics_enabled",
|
||||
JavaMinimizeDependencyJars = "java_minimize_dependency_jars",
|
||||
OverlayAnalysis = "overlay_analysis",
|
||||
OverlayAnalysisActions = "overlay_analysis_actions",
|
||||
OverlayAnalysisCodeScanningActions = "overlay_analysis_code_scanning_actions",
|
||||
@@ -168,11 +167,6 @@ export const featureConfig: Record<
|
||||
legacyApi: true,
|
||||
minimumVersion: undefined,
|
||||
},
|
||||
[Feature.JavaMinimizeDependencyJars]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
||||
minimumVersion: "2.23.0",
|
||||
},
|
||||
[Feature.OverlayAnalysis]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||
|
||||
+16
-7
@@ -88,6 +88,13 @@ import {
|
||||
} from "./util";
|
||||
import { checkWorkflow } from "./workflow";
|
||||
|
||||
/**
|
||||
* First version of CodeQL where the Java extractor safely supports the option to minimize
|
||||
* dependency jars. Note: some earlier versions of the extractor will respond to the corresponding
|
||||
* option, but may rewrite jars in ways that lead to extraction errors.
|
||||
*/
|
||||
export const CODEQL_VERSION_JAR_MINIMIZATION = "2.23.0";
|
||||
|
||||
/**
|
||||
* Sends a status report indicating that the `init` Action is starting.
|
||||
*
|
||||
@@ -638,18 +645,20 @@ async function run() {
|
||||
}
|
||||
}
|
||||
|
||||
// If the feature flag to minimize Java dependency jars is enabled, and we are doing a Java
|
||||
// `build-mode: none` analysis (i.e. the flag is relevant), then set the environment variable
|
||||
// that enables the corresponding option in the Java extractor. We also only do this if
|
||||
// dependency caching is enabled, since the option is intended to reduce the size of
|
||||
// dependency caches, but the jar-rewriting does have a performance cost that we'd like to avoid
|
||||
// when caching is not being used.
|
||||
// If we are doing a Java `build-mode: none` analysis, then set the environment variable that
|
||||
// enables the option in the Java extractor to minimize dependency jars. We also only do this if
|
||||
// dependency caching is enabled, since the option is intended to reduce the size of dependency
|
||||
// caches, but the jar-rewriting does have a performance cost that we'd like to avoid when
|
||||
// caching is not being used.
|
||||
// TODO: Remove this language-specific mechanism and replace it with a more general one that
|
||||
// tells extractors when dependency caching is enabled, and then the Java extractor can make its
|
||||
// own decision about whether to rewrite jars.
|
||||
if (process.env[EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS]) {
|
||||
logger.debug(
|
||||
`${EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS} is already set to '${process.env[EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS]}', so the Action will not override it.`,
|
||||
);
|
||||
} else if (
|
||||
(await features.getValue(Feature.JavaMinimizeDependencyJars, codeql)) &&
|
||||
(await codeQlVersionAtLeast(codeql, CODEQL_VERSION_JAR_MINIMIZATION)) &&
|
||||
config.dependencyCachingEnabled &&
|
||||
config.buildMode === BuildMode.None &&
|
||||
config.languages.includes(KnownLanguage.java)
|
||||
|
||||
Reference in New Issue
Block a user