Skip to content

Commit bcdb4ec

Browse files
committed
Unconditionally disable combining SARIF files for GHES 3.18
1 parent c0809df commit bcdb4ec

File tree

6 files changed

+92
-20
lines changed

6 files changed

+92
-20
lines changed

lib/upload-lib.js

Lines changed: 14 additions & 5 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.

lib/upload-lib.test.js

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

lib/upload-lib.test.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/upload-lib.test.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ test("throwIfCombineSarifFilesDisabled when on GHES 3.13", async (t) => {
446446
await t.notThrowsAsync(
447447
uploadLib.throwIfCombineSarifFilesDisabled(
448448
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
449-
createFeatures([Feature.DisableCombineSarifFiles]),
449+
createFeatures([]),
450450
{
451451
type: GitHubVariant.GHES,
452452
version: "3.13.2",
@@ -459,7 +459,7 @@ test("throwIfCombineSarifFilesDisabled when on GHES 3.14", async (t) => {
459459
await t.notThrowsAsync(
460460
uploadLib.throwIfCombineSarifFilesDisabled(
461461
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
462-
createFeatures([Feature.DisableCombineSarifFiles]),
462+
createFeatures([]),
463463
{
464464
type: GitHubVariant.GHES,
465465
version: "3.14.0",
@@ -468,11 +468,50 @@ test("throwIfCombineSarifFilesDisabled when on GHES 3.14", async (t) => {
468468
);
469469
});
470470

471+
test("throwIfCombineSarifFilesDisabled when on GHES 3.17", async (t) => {
472+
await t.notThrowsAsync(
473+
uploadLib.throwIfCombineSarifFilesDisabled(
474+
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
475+
createFeatures([]),
476+
{
477+
type: GitHubVariant.GHES,
478+
version: "3.17.0",
479+
},
480+
),
481+
);
482+
});
483+
484+
test("throwIfCombineSarifFilesDisabled when on GHES 3.18 pre", async (t) => {
485+
await t.throwsAsync(
486+
uploadLib.throwIfCombineSarifFilesDisabled(
487+
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
488+
createFeatures([]),
489+
{
490+
type: GitHubVariant.GHES,
491+
version: "3.18.0.pre1",
492+
},
493+
),
494+
);
495+
});
496+
497+
test("throwIfCombineSarifFilesDisabled when on GHES 3.18 alpha", async (t) => {
498+
await t.throwsAsync(
499+
uploadLib.throwIfCombineSarifFilesDisabled(
500+
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
501+
createFeatures([]),
502+
{
503+
type: GitHubVariant.GHES,
504+
version: "3.18.0-alpha.1",
505+
},
506+
),
507+
);
508+
});
509+
471510
test("throwIfCombineSarifFilesDisabled when on GHES 3.18", async (t) => {
472511
await t.throwsAsync(
473512
uploadLib.throwIfCombineSarifFilesDisabled(
474513
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
475-
createFeatures([Feature.DisableCombineSarifFiles]),
514+
createFeatures([]),
476515
{
477516
type: GitHubVariant.GHES,
478517
version: "3.18.0",

src/upload-lib.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,26 @@ async function shouldDisableCombineSarifFiles(
175175
features: FeatureEnablement,
176176
githubVersion: GitHubVersion,
177177
) {
178-
// Never block on GHES versions before 3.18.0
179-
if (
180-
githubVersion.type === GitHubVariant.GHES &&
181-
semver.lt(githubVersion.version, "3.18.0")
182-
) {
183-
return false;
178+
if (githubVersion.type === GitHubVariant.GHES) {
179+
// Never block on GHES versions before 3.18.
180+
if (semver.lt(githubVersion.version, "3.18.0-0")) {
181+
return false;
182+
}
183+
} else {
184+
// Never block when the feature flag is disabled.
185+
if (!(await features.getValue(Feature.DisableCombineSarifFiles))) {
186+
return false;
187+
}
184188
}
185189

186190
if (areAllRunsUnique(sarifObjects)) {
187191
// If all runs are unique, we can safely combine them.
188192
return false;
189193
}
190194

191-
return features.getValue(Feature.DisableCombineSarifFiles);
195+
// Combining SARIF files is not supported and Code Scanning will return an
196+
// error if multiple runs with the same category are uploaded.
197+
return true;
192198
}
193199

194200
// Takes a list of paths to sarif files and combines them together using the

0 commit comments

Comments
 (0)