Skip to content

Commit e20c273

Browse files
committed
Use supportsFeature check for merging SARIF files
1 parent 2bbafcd commit e20c273

9 files changed

+27
-9
lines changed

lib/feature-flags.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/feature-flags.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tools-features.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tools-features.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/feature-flags.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ export const featureConfig: Record<
6161
> = {
6262
[Feature.CliSarifMerge]: {
6363
envVar: "CODEQL_ACTION_CLI_SARIF_MERGE",
64-
// This feature is only supported in 2.17.0, but we'll want to test this feature
65-
// with nightly builds before that. We'll update this to 2.17.0 once it's released.
64+
// This is guarded by a `supportsFeature` check rather than by a version check.
6665
minimumVersion: undefined,
6766
defaultValue: false,
6867
},

src/tools-features.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export enum ToolsFeature {
66
InformsAboutUnsupportedPathFilters = "informsAboutUnsupportedPathFilters",
77
SetsCodeqlRunnerEnvVar = "setsCodeqlRunnerEnvVar",
88
TraceCommandUseBuildMode = "traceCommandUseBuildMode",
9+
SarifMergeRunsFromEqualCategory = "sarifMergeRunsFromEqualCategory",
910
}
1011

1112
/**

src/upload-lib.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ import * as fingerprints from "./fingerprints";
1919
import { initCodeQL } from "./init";
2020
import { Logger } from "./logging";
2121
import { parseRepositoryNwo, RepositoryNwo } from "./repository";
22+
import { ToolsFeature } from "./tools-features";
2223
import * as util from "./util";
2324
import {
24-
SarifFile,
2525
ConfigurationError,
26-
wrapError,
2726
getRequiredEnvParam,
2827
GitHubVersion,
28+
SarifFile,
29+
wrapError,
2930
} from "./util";
3031

3132
const GENERIC_403_MSG =
@@ -134,6 +135,18 @@ async function combineSarifFilesUsingCLI(
134135
codeQL = initCodeQLResult.codeql;
135136
}
136137

138+
if (
139+
!(await codeQL.supportsFeature(
140+
ToolsFeature.SarifMergeRunsFromEqualCategory,
141+
))
142+
) {
143+
logger.warning(
144+
"The CodeQL CLI does not support merging SARIF files. Merging files in the action.",
145+
);
146+
147+
return combineSarifFiles(sarifFiles);
148+
}
149+
137150
const baseTempDir = path.resolve(tempDir, "combined-sarif");
138151
fs.mkdirSync(baseTempDir, { recursive: true });
139152
const outputDirectory = fs.mkdtempSync(path.resolve(baseTempDir, "output-"));

0 commit comments

Comments
 (0)