Remove feature flag for combine SARIF files deprecation warning

This commit is contained in:
Koen Vlaswinkel 2024-05-14 11:00:12 +02:00
parent 08487dbb93
commit 931fabe1ef
9 changed files with 17 additions and 69 deletions

8
lib/feature-flags.js generated
View file

@ -50,7 +50,6 @@ exports.CODEQL_VERSION_FINE_GRAINED_PARALLELISM = "2.15.1";
var Feature; var Feature;
(function (Feature) { (function (Feature) {
Feature["AutobuildDirectTracing"] = "autobuild_direct_tracing"; Feature["AutobuildDirectTracing"] = "autobuild_direct_tracing";
Feature["CombineSarifFilesDeprecationWarning"] = "combine_sarif_files_deprecation_warning_enabled";
Feature["CppDependencyInstallation"] = "cpp_dependency_installation_enabled"; Feature["CppDependencyInstallation"] = "cpp_dependency_installation_enabled";
Feature["CppTrapCachingEnabled"] = "cpp_trap_caching_enabled"; Feature["CppTrapCachingEnabled"] = "cpp_trap_caching_enabled";
Feature["DisableJavaBuildlessEnabled"] = "disable_java_buildless_enabled"; Feature["DisableJavaBuildlessEnabled"] = "disable_java_buildless_enabled";
@ -65,13 +64,6 @@ exports.featureConfig = {
minimumVersion: undefined, minimumVersion: undefined,
toolsFeature: tools_features_1.ToolsFeature.TraceCommandUseBuildMode, toolsFeature: tools_features_1.ToolsFeature.TraceCommandUseBuildMode,
}, },
[Feature.CombineSarifFilesDeprecationWarning]: {
defaultValue: false,
envVar: "CODEQL_ACTION_COMBINE_SARIF_FILES_DEPRECATION_WARNING",
legacyApi: true,
// Independent of the CLI version.
minimumVersion: undefined,
},
[Feature.CppDependencyInstallation]: { [Feature.CppDependencyInstallation]: {
defaultValue: false, defaultValue: false,
envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES", envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES",

File diff suppressed because one or more lines are too long

9
lib/upload-lib.js generated
View file

@ -111,10 +111,7 @@ function areAllRunsUnique(sarifObjects) {
return true; return true;
} }
// Checks whether the deprecation warning for combining SARIF files should be shown. // Checks whether the deprecation warning for combining SARIF files should be shown.
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, features, githubVersion) { async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
if (!(await features.getValue(feature_flags_1.Feature.CombineSarifFilesDeprecationWarning))) {
return false;
}
// Do not show this warning on GHES versions before 3.14.0 // Do not show this warning on GHES versions before 3.14.0
if (githubVersion.type === util_1.GitHubVariant.GHES && if (githubVersion.type === util_1.GitHubVariant.GHES &&
semver.lt(githubVersion.version, "3.14.0")) { semver.lt(githubVersion.version, "3.14.0")) {
@ -144,7 +141,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload"; const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload";
if (!areAllRunsProducedByCodeQL(sarifObjects)) { if (!areAllRunsProducedByCodeQL(sarifObjects)) {
logger.debug("Not all SARIF files were produced by CodeQL. Merging files in the action."); logger.debug("Not all SARIF files were produced by CodeQL. Merging files in the action.");
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, features, gitHubVersion)) { if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, gitHubVersion)) {
logger.warning(`Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`); logger.warning(`Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`);
core.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); core.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true");
} }
@ -175,7 +172,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
} }
if (!(await codeQL.supportsFeature(tools_features_1.ToolsFeature.SarifMergeRunsFromEqualCategory))) { if (!(await codeQL.supportsFeature(tools_features_1.ToolsFeature.SarifMergeRunsFromEqualCategory))) {
logger.warning("The CodeQL CLI does not support merging SARIF files. Merging files in the action."); logger.warning("The CodeQL CLI does not support merging SARIF files. Merging files in the action.");
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, features, gitHubVersion)) { if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, gitHubVersion)) {
logger.warning(`Uploading multiple CodeQL runs with the same category is deprecated ${deprecationWarningMessage} for CodeQL CLI 2.16.6 and earlier. Please update your CodeQL CLI version or update your workflow to set a distinct category for each CodeQL run. ${deprecationMoreInformationMessage}`); logger.warning(`Uploading multiple CodeQL runs with the same category is deprecated ${deprecationWarningMessage} for CodeQL CLI 2.16.6 and earlier. Please update your CodeQL CLI version or update your workflow to set a distinct category for each CodeQL run. ${deprecationMoreInformationMessage}`);
core.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); core.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true");
} }

File diff suppressed because one or more lines are too long

22
lib/upload-lib.test.js generated
View file

@ -29,7 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const ava_1 = __importDefault(require("ava")); const ava_1 = __importDefault(require("ava"));
const feature_flags_1 = require("./feature-flags");
const logging_1 = require("./logging"); const logging_1 = require("./logging");
const testing_utils_1 = require("./testing-utils"); const testing_utils_1 = require("./testing-utils");
const uploadLib = __importStar(require("./upload-lib")); const uploadLib = __importStar(require("./upload-lib"));
@ -196,46 +195,41 @@ ava_1.default.beforeEach(() => {
t.deepEqual(loggedMessages.length, 2); t.deepEqual(loggedMessages.length, 2);
t.deepEqual(loggedMessages[1], "Warning: 'not a valid URI' is not a valid URI in 'instance.runs[0].results[0].locations[0].physicalLocation.artifactLocation.uri'."); t.deepEqual(loggedMessages[1], "Warning: 'not a valid URI' is not a valid URI in 'instance.runs[0].results[0].locations[0].physicalLocation.artifactLocation.uri'.");
}); });
(0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning when on dotcom with feature flag", async (t) => { (0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning when on dotcom", async (t) => {
t.true(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CombineSarifFilesDeprecationWarning]), { t.true(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], {
type: util_1.GitHubVariant.DOTCOM,
}));
});
(0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning without feature flag", async (t) => {
t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([]), {
type: util_1.GitHubVariant.DOTCOM, type: util_1.GitHubVariant.DOTCOM,
})); }));
}); });
(0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.13", async (t) => { (0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.13", async (t) => {
t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CombineSarifFilesDeprecationWarning]), { t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], {
type: util_1.GitHubVariant.GHES, type: util_1.GitHubVariant.GHES,
version: "3.13.2", version: "3.13.2",
})); }));
}); });
(0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.14", async (t) => { (0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.14", async (t) => {
t.true(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CombineSarifFilesDeprecationWarning]), { t.true(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], {
type: util_1.GitHubVariant.GHES, type: util_1.GitHubVariant.GHES,
version: "3.14.0", version: "3.14.0",
})); }));
}); });
(0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning with only 1 run", async (t) => { (0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning with only 1 run", async (t) => {
t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CombineSarifFilesDeprecationWarning]), { t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def")], {
type: util_1.GitHubVariant.DOTCOM, type: util_1.GitHubVariant.DOTCOM,
})); }));
}); });
(0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning with distinct categories", async (t) => { (0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning with distinct categories", async (t) => {
t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("def", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CombineSarifFilesDeprecationWarning]), { t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("def", "def")], {
type: util_1.GitHubVariant.DOTCOM, type: util_1.GitHubVariant.DOTCOM,
})); }));
}); });
(0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning with distinct tools", async (t) => { (0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning with distinct tools", async (t) => {
t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "abc"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CombineSarifFilesDeprecationWarning]), { t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "abc"), createMockSarif("abc", "def")], {
type: util_1.GitHubVariant.DOTCOM, type: util_1.GitHubVariant.DOTCOM,
})); }));
}); });
(0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning when environment variable is already set", async (t) => { (0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning when environment variable is already set", async (t) => {
process.env["CODEQL_MERGE_SARIF_DEPRECATION_WARNING"] = "true"; process.env["CODEQL_MERGE_SARIF_DEPRECATION_WARNING"] = "true";
t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.CombineSarifFilesDeprecationWarning]), { t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], {
type: util_1.GitHubVariant.DOTCOM, type: util_1.GitHubVariant.DOTCOM,
})); }));
}); });

File diff suppressed because one or more lines are too long

View file

@ -46,7 +46,6 @@ export interface FeatureEnablement {
*/ */
export enum Feature { export enum Feature {
AutobuildDirectTracing = "autobuild_direct_tracing", AutobuildDirectTracing = "autobuild_direct_tracing",
CombineSarifFilesDeprecationWarning = "combine_sarif_files_deprecation_warning_enabled",
CppDependencyInstallation = "cpp_dependency_installation_enabled", CppDependencyInstallation = "cpp_dependency_installation_enabled",
CppTrapCachingEnabled = "cpp_trap_caching_enabled", CppTrapCachingEnabled = "cpp_trap_caching_enabled",
DisableJavaBuildlessEnabled = "disable_java_buildless_enabled", DisableJavaBuildlessEnabled = "disable_java_buildless_enabled",
@ -92,13 +91,6 @@ export const featureConfig: Record<
minimumVersion: undefined, minimumVersion: undefined,
toolsFeature: ToolsFeature.TraceCommandUseBuildMode, toolsFeature: ToolsFeature.TraceCommandUseBuildMode,
}, },
[Feature.CombineSarifFilesDeprecationWarning]: {
defaultValue: false,
envVar: "CODEQL_ACTION_COMBINE_SARIF_FILES_DEPRECATION_WARNING",
legacyApi: true,
// Independent of the CLI version.
minimumVersion: undefined,
},
[Feature.CppDependencyInstallation]: { [Feature.CppDependencyInstallation]: {
defaultValue: false, defaultValue: false,
envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES", envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES",

View file

@ -3,9 +3,8 @@ import * as path from "path";
import test from "ava"; import test from "ava";
import { Feature } from "./feature-flags";
import { getRunnerLogger, Logger } from "./logging"; import { getRunnerLogger, Logger } from "./logging";
import { createFeatures, setupTests } from "./testing-utils"; import { setupTests } from "./testing-utils";
import * as uploadLib from "./upload-lib"; import * as uploadLib from "./upload-lib";
import { GitHubVariant, initializeEnvironment, withTmpDir } from "./util"; import { GitHubVariant, initializeEnvironment, withTmpDir } from "./util";
@ -325,23 +324,10 @@ test("accept results with invalid artifactLocation.uri value", (t) => {
); );
}); });
test("shouldShowCombineSarifFilesDeprecationWarning when on dotcom with feature flag", async (t) => { test("shouldShowCombineSarifFilesDeprecationWarning when on dotcom", async (t) => {
t.true( t.true(
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning( await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
[createMockSarif("abc", "def"), createMockSarif("abc", "def")], [createMockSarif("abc", "def"), createMockSarif("abc", "def")],
createFeatures([Feature.CombineSarifFilesDeprecationWarning]),
{
type: GitHubVariant.DOTCOM,
},
),
);
});
test("shouldShowCombineSarifFilesDeprecationWarning without feature flag", async (t) => {
t.false(
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
createFeatures([]),
{ {
type: GitHubVariant.DOTCOM, type: GitHubVariant.DOTCOM,
}, },
@ -353,7 +339,6 @@ test("shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.13", async (t
t.false( t.false(
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning( await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
[createMockSarif("abc", "def"), createMockSarif("abc", "def")], [createMockSarif("abc", "def"), createMockSarif("abc", "def")],
createFeatures([Feature.CombineSarifFilesDeprecationWarning]),
{ {
type: GitHubVariant.GHES, type: GitHubVariant.GHES,
version: "3.13.2", version: "3.13.2",
@ -366,7 +351,6 @@ test("shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.14", async (t
t.true( t.true(
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning( await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
[createMockSarif("abc", "def"), createMockSarif("abc", "def")], [createMockSarif("abc", "def"), createMockSarif("abc", "def")],
createFeatures([Feature.CombineSarifFilesDeprecationWarning]),
{ {
type: GitHubVariant.GHES, type: GitHubVariant.GHES,
version: "3.14.0", version: "3.14.0",
@ -379,7 +363,6 @@ test("shouldShowCombineSarifFilesDeprecationWarning with only 1 run", async (t)
t.false( t.false(
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning( await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
[createMockSarif("abc", "def")], [createMockSarif("abc", "def")],
createFeatures([Feature.CombineSarifFilesDeprecationWarning]),
{ {
type: GitHubVariant.DOTCOM, type: GitHubVariant.DOTCOM,
}, },
@ -391,7 +374,6 @@ test("shouldShowCombineSarifFilesDeprecationWarning with distinct categories", a
t.false( t.false(
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning( await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
[createMockSarif("abc", "def"), createMockSarif("def", "def")], [createMockSarif("abc", "def"), createMockSarif("def", "def")],
createFeatures([Feature.CombineSarifFilesDeprecationWarning]),
{ {
type: GitHubVariant.DOTCOM, type: GitHubVariant.DOTCOM,
}, },
@ -403,7 +385,6 @@ test("shouldShowCombineSarifFilesDeprecationWarning with distinct tools", async
t.false( t.false(
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning( await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
[createMockSarif("abc", "abc"), createMockSarif("abc", "def")], [createMockSarif("abc", "abc"), createMockSarif("abc", "def")],
createFeatures([Feature.CombineSarifFilesDeprecationWarning]),
{ {
type: GitHubVariant.DOTCOM, type: GitHubVariant.DOTCOM,
}, },
@ -417,7 +398,6 @@ test("shouldShowCombineSarifFilesDeprecationWarning when environment variable is
t.false( t.false(
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning( await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
[createMockSarif("abc", "def"), createMockSarif("abc", "def")], [createMockSarif("abc", "def"), createMockSarif("abc", "def")],
createFeatures([Feature.CombineSarifFilesDeprecationWarning]),
{ {
type: GitHubVariant.DOTCOM, type: GitHubVariant.DOTCOM,
}, },

View file

@ -15,7 +15,7 @@ import { getGitHubVersion, wrapApiConfigurationError } from "./api-client";
import { CodeQL, getCodeQL } from "./codeql"; import { CodeQL, getCodeQL } from "./codeql";
import { getConfig } from "./config-utils"; import { getConfig } from "./config-utils";
import { EnvVar } from "./environment"; import { EnvVar } from "./environment";
import { Feature, FeatureEnablement, Features } from "./feature-flags"; import { FeatureEnablement, Features } from "./feature-flags";
import * as fingerprints from "./fingerprints"; import * as fingerprints from "./fingerprints";
import { initCodeQL } from "./init"; import { initCodeQL } from "./init";
import { Logger } from "./logging"; import { Logger } from "./logging";
@ -125,13 +125,8 @@ function areAllRunsUnique(sarifObjects: SarifFile[]): boolean {
// Checks whether the deprecation warning for combining SARIF files should be shown. // Checks whether the deprecation warning for combining SARIF files should be shown.
export async function shouldShowCombineSarifFilesDeprecationWarning( export async function shouldShowCombineSarifFilesDeprecationWarning(
sarifObjects: util.SarifFile[], sarifObjects: util.SarifFile[],
features: FeatureEnablement,
githubVersion: GitHubVersion, githubVersion: GitHubVersion,
) { ) {
if (!(await features.getValue(Feature.CombineSarifFilesDeprecationWarning))) {
return false;
}
// Do not show this warning on GHES versions before 3.14.0 // Do not show this warning on GHES versions before 3.14.0
if ( if (
githubVersion.type === GitHubVariant.GHES && githubVersion.type === GitHubVariant.GHES &&
@ -182,7 +177,6 @@ async function combineSarifFilesUsingCLI(
if ( if (
await shouldShowCombineSarifFilesDeprecationWarning( await shouldShowCombineSarifFilesDeprecationWarning(
sarifObjects, sarifObjects,
features,
gitHubVersion, gitHubVersion,
) )
) { ) {
@ -245,7 +239,6 @@ async function combineSarifFilesUsingCLI(
if ( if (
await shouldShowCombineSarifFilesDeprecationWarning( await shouldShowCombineSarifFilesDeprecationWarning(
sarifObjects, sarifObjects,
features,
gitHubVersion, gitHubVersion,
) )
) { ) {