mirror of
https://github.com/github/codeql-action.git
synced 2026-01-06 06:30:10 +08:00
Fix parsing of GHES pre-release versions
This commit is contained in:
4
lib/upload-lib.js
generated
4
lib/upload-lib.js
generated
@@ -138,7 +138,7 @@ function areAllRunsUnique(sarifObjects) {
|
|||||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
||||||
// 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((0, util_1.parseGhesVersion)(githubVersion.version), "3.14.0")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Only give a deprecation warning when not all runs are unique and
|
// Only give a deprecation warning when not all runs are unique and
|
||||||
@@ -158,7 +158,7 @@ async function throwIfCombineSarifFilesDisabled(sarifObjects, features, githubVe
|
|||||||
async function shouldDisableCombineSarifFiles(sarifObjects, features, githubVersion) {
|
async function shouldDisableCombineSarifFiles(sarifObjects, features, githubVersion) {
|
||||||
if (githubVersion.type === util_1.GitHubVariant.GHES) {
|
if (githubVersion.type === util_1.GitHubVariant.GHES) {
|
||||||
// Never block on GHES versions before 3.18.
|
// Never block on GHES versions before 3.18.
|
||||||
if (semver.lt(githubVersion.version, "3.18.0-0")) {
|
if (semver.lt((0, util_1.parseGhesVersion)(githubVersion.version), "3.18.0-0")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
22
lib/upload-lib.test.js
generated
22
lib/upload-lib.test.js
generated
@@ -224,6 +224,12 @@ ava_1.default.beforeEach(() => {
|
|||||||
version: "3.14.0",
|
version: "3.14.0",
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
(0, ava_1.default)("shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.16 pre", async (t) => {
|
||||||
|
t.true(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def"), createMockSarif("abc", "def")], {
|
||||||
|
type: util_1.GitHubVariant.GHES,
|
||||||
|
version: "3.16.0.pre1",
|
||||||
|
}));
|
||||||
|
});
|
||||||
(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")], {
|
t.false(await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([createMockSarif("abc", "def")], {
|
||||||
type: util_1.GitHubVariant.DOTCOM,
|
type: util_1.GitHubVariant.DOTCOM,
|
||||||
@@ -248,7 +254,9 @@ ava_1.default.beforeEach(() => {
|
|||||||
(0, ava_1.default)("throwIfCombineSarifFilesDisabled when on dotcom with feature flag", async (t) => {
|
(0, ava_1.default)("throwIfCombineSarifFilesDisabled when on dotcom with feature flag", async (t) => {
|
||||||
await t.throwsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.DisableCombineSarifFiles]), {
|
await t.throwsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.DisableCombineSarifFiles]), {
|
||||||
type: util_1.GitHubVariant.DOTCOM,
|
type: util_1.GitHubVariant.DOTCOM,
|
||||||
}));
|
}), {
|
||||||
|
message: /The CodeQL Action does not support uploading multiple SARIF runs with the same category/,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("throwIfCombineSarifFilesDisabled when on dotcom without feature flag", async (t) => {
|
(0, ava_1.default)("throwIfCombineSarifFilesDisabled when on dotcom without feature flag", async (t) => {
|
||||||
await t.notThrowsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([]), {
|
await t.notThrowsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([]), {
|
||||||
@@ -277,19 +285,25 @@ ava_1.default.beforeEach(() => {
|
|||||||
await t.throwsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([]), {
|
await t.throwsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([]), {
|
||||||
type: util_1.GitHubVariant.GHES,
|
type: util_1.GitHubVariant.GHES,
|
||||||
version: "3.18.0.pre1",
|
version: "3.18.0.pre1",
|
||||||
}));
|
}), {
|
||||||
|
message: /The CodeQL Action does not support uploading multiple SARIF runs with the same category/,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("throwIfCombineSarifFilesDisabled when on GHES 3.18 alpha", async (t) => {
|
(0, ava_1.default)("throwIfCombineSarifFilesDisabled when on GHES 3.18 alpha", async (t) => {
|
||||||
await t.throwsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([]), {
|
await t.throwsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([]), {
|
||||||
type: util_1.GitHubVariant.GHES,
|
type: util_1.GitHubVariant.GHES,
|
||||||
version: "3.18.0-alpha.1",
|
version: "3.18.0-alpha.1",
|
||||||
}));
|
}), {
|
||||||
|
message: /The CodeQL Action does not support uploading multiple SARIF runs with the same category/,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("throwIfCombineSarifFilesDisabled when on GHES 3.18", async (t) => {
|
(0, ava_1.default)("throwIfCombineSarifFilesDisabled when on GHES 3.18", async (t) => {
|
||||||
await t.throwsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([]), {
|
await t.throwsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def"), createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([]), {
|
||||||
type: util_1.GitHubVariant.GHES,
|
type: util_1.GitHubVariant.GHES,
|
||||||
version: "3.18.0",
|
version: "3.18.0",
|
||||||
}));
|
}), {
|
||||||
|
message: /The CodeQL Action does not support uploading multiple SARIF runs with the same category/,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("throwIfCombineSarifFilesDisabled with only 1 run", async (t) => {
|
(0, ava_1.default)("throwIfCombineSarifFilesDisabled with only 1 run", async (t) => {
|
||||||
await t.notThrowsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.DisableCombineSarifFiles]), {
|
await t.notThrowsAsync(uploadLib.throwIfCombineSarifFilesDisabled([createMockSarif("abc", "def")], (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.DisableCombineSarifFiles]), {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
8
lib/util.js
generated
8
lib/util.js
generated
@@ -77,6 +77,7 @@ exports.getErrorMessage = getErrorMessage;
|
|||||||
exports.prettyPrintPack = prettyPrintPack;
|
exports.prettyPrintPack = prettyPrintPack;
|
||||||
exports.checkDiskUsage = checkDiskUsage;
|
exports.checkDiskUsage = checkDiskUsage;
|
||||||
exports.checkActionVersion = checkActionVersion;
|
exports.checkActionVersion = checkActionVersion;
|
||||||
|
exports.parseGhesVersion = parseGhesVersion;
|
||||||
exports.cloneObject = cloneObject;
|
exports.cloneObject = cloneObject;
|
||||||
exports.checkSipEnablement = checkSipEnablement;
|
exports.checkSipEnablement = checkSipEnablement;
|
||||||
exports.cleanUpGlob = cleanUpGlob;
|
exports.cleanUpGlob = cleanUpGlob;
|
||||||
@@ -887,6 +888,13 @@ function checkActionVersion(version, githubVersion) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function parseGhesVersion(version) {
|
||||||
|
// GHES pre-release versions are in the format "3.18.0.pre1", which is not a valid semver version.
|
||||||
|
if (version.includes(".pre")) {
|
||||||
|
version = version.replace(".pre", "-pre");
|
||||||
|
}
|
||||||
|
return new semver.SemVer(version);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Supported build modes.
|
* Supported build modes.
|
||||||
*
|
*
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -372,6 +372,18 @@ test("shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.14", async (t
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.16 pre", async (t) => {
|
||||||
|
t.true(
|
||||||
|
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||||
|
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
|
||||||
|
{
|
||||||
|
type: GitHubVariant.GHES,
|
||||||
|
version: "3.16.0.pre1",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("shouldShowCombineSarifFilesDeprecationWarning with only 1 run", async (t) => {
|
test("shouldShowCombineSarifFilesDeprecationWarning with only 1 run", async (t) => {
|
||||||
t.false(
|
t.false(
|
||||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||||
@@ -427,6 +439,10 @@ test("throwIfCombineSarifFilesDisabled when on dotcom with feature flag", async
|
|||||||
type: GitHubVariant.DOTCOM,
|
type: GitHubVariant.DOTCOM,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
{
|
||||||
|
message:
|
||||||
|
/The CodeQL Action does not support uploading multiple SARIF runs with the same category/,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -491,6 +507,10 @@ test("throwIfCombineSarifFilesDisabled when on GHES 3.18 pre", async (t) => {
|
|||||||
version: "3.18.0.pre1",
|
version: "3.18.0.pre1",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
{
|
||||||
|
message:
|
||||||
|
/The CodeQL Action does not support uploading multiple SARIF runs with the same category/,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -504,6 +524,10 @@ test("throwIfCombineSarifFilesDisabled when on GHES 3.18 alpha", async (t) => {
|
|||||||
version: "3.18.0-alpha.1",
|
version: "3.18.0-alpha.1",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
{
|
||||||
|
message:
|
||||||
|
/The CodeQL Action does not support uploading multiple SARIF runs with the same category/,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -517,6 +541,10 @@ test("throwIfCombineSarifFilesDisabled when on GHES 3.18", async (t) => {
|
|||||||
version: "3.18.0",
|
version: "3.18.0",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
{
|
||||||
|
message:
|
||||||
|
/The CodeQL Action does not support uploading multiple SARIF runs with the same category/,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import {
|
|||||||
getRequiredEnvParam,
|
getRequiredEnvParam,
|
||||||
GitHubVariant,
|
GitHubVariant,
|
||||||
GitHubVersion,
|
GitHubVersion,
|
||||||
|
parseGhesVersion,
|
||||||
SarifFile,
|
SarifFile,
|
||||||
SarifRun,
|
SarifRun,
|
||||||
} from "./util";
|
} from "./util";
|
||||||
@@ -132,7 +133,7 @@ export async function shouldShowCombineSarifFilesDeprecationWarning(
|
|||||||
// 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 &&
|
||||||
semver.lt(githubVersion.version, "3.14.0")
|
semver.lt(parseGhesVersion(githubVersion.version), "3.14.0")
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -177,7 +178,7 @@ async function shouldDisableCombineSarifFiles(
|
|||||||
) {
|
) {
|
||||||
if (githubVersion.type === GitHubVariant.GHES) {
|
if (githubVersion.type === GitHubVariant.GHES) {
|
||||||
// Never block on GHES versions before 3.18.
|
// Never block on GHES versions before 3.18.
|
||||||
if (semver.lt(githubVersion.version, "3.18.0-0")) {
|
if (semver.lt(parseGhesVersion(githubVersion.version), "3.18.0-0")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1132,6 +1132,14 @@ export function checkActionVersion(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function parseGhesVersion(version: string): semver.SemVer {
|
||||||
|
// GHES pre-release versions are in the format "3.18.0.pre1", which is not a valid semver version.
|
||||||
|
if (version.includes(".pre")) {
|
||||||
|
version = version.replace(".pre", "-pre");
|
||||||
|
}
|
||||||
|
return new semver.SemVer(version);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supported build modes.
|
* Supported build modes.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user