mirror of
https://github.com/github/codeql-action
synced 2026-06-01 20:01:46 +03:00
Move formatGitHubVersion into util.test.ts
This commit is contained in:
Generated
+1
-14
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.formatGitHubVersion = exports.checkActionVersion = exports.getMlPoweredJsQueriesStatus = exports.getMlPoweredJsQueriesPack = exports.ML_POWERED_JS_QUERIES_PACK_NAME = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isGitHubGhesVersionBelow = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
||||
exports.checkActionVersion = exports.getMlPoweredJsQueriesStatus = exports.getMlPoweredJsQueriesPack = exports.ML_POWERED_JS_QUERIES_PACK_NAME = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isGitHubGhesVersionBelow = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
@@ -619,17 +619,4 @@ async function checkActionVersion(version) {
|
||||
}
|
||||
}
|
||||
exports.checkActionVersion = checkActionVersion;
|
||||
function formatGitHubVersion(version) {
|
||||
switch (version.type) {
|
||||
case GitHubVariant.DOTCOM:
|
||||
return "dotcom";
|
||||
case GitHubVariant.GHAE:
|
||||
return "GHAE";
|
||||
case GitHubVariant.GHES:
|
||||
return `GHES ${version.version}`;
|
||||
default:
|
||||
assertNever(version);
|
||||
}
|
||||
}
|
||||
exports.formatGitHubVersion = formatGitHubVersion;
|
||||
//# sourceMappingURL=util.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+13
-1
@@ -282,6 +282,18 @@ for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
||||
t.falsy(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.2.0" }, "3.2.0"));
|
||||
t.true(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.1.2" }, "3.2.0"));
|
||||
});
|
||||
function formatGitHubVersion(version) {
|
||||
switch (version.type) {
|
||||
case util.GitHubVariant.DOTCOM:
|
||||
return "dotcom";
|
||||
case util.GitHubVariant.GHAE:
|
||||
return "GHAE";
|
||||
case util.GitHubVariant.GHES:
|
||||
return `GHES ${version.version}`;
|
||||
default:
|
||||
util.assertNever(version);
|
||||
}
|
||||
}
|
||||
const CHECK_ACTION_VERSION_TESTS = [
|
||||
["1.2.1", { type: util.GitHubVariant.DOTCOM }, true],
|
||||
["1.2.1", { type: util.GitHubVariant.GHAE }, true],
|
||||
@@ -298,7 +310,7 @@ for (const [version, githubVersion, shouldReportWarning,] of CHECK_ACTION_VERSIO
|
||||
const reportWarningDescription = shouldReportWarning
|
||||
? "reports warning"
|
||||
: "doesn't report warning";
|
||||
const versionsDescription = `CodeQL Action version ${version} and GitHub version ${util.formatGitHubVersion(githubVersion)}`;
|
||||
const versionsDescription = `CodeQL Action version ${version} and GitHub version ${formatGitHubVersion(githubVersion)}`;
|
||||
(0, ava_1.default)(`checkActionVersion ${reportWarningDescription} for ${versionsDescription}`, async (t) => {
|
||||
const warningSpy = sinon.spy(core, "warning");
|
||||
const versionStub = sinon
|
||||
|
||||
File diff suppressed because one or more lines are too long
+14
-1
@@ -394,6 +394,19 @@ test("isGitHubGhesVersionBelow", async (t) => {
|
||||
);
|
||||
});
|
||||
|
||||
function formatGitHubVersion(version: util.GitHubVersion): string {
|
||||
switch (version.type) {
|
||||
case util.GitHubVariant.DOTCOM:
|
||||
return "dotcom";
|
||||
case util.GitHubVariant.GHAE:
|
||||
return "GHAE";
|
||||
case util.GitHubVariant.GHES:
|
||||
return `GHES ${version.version}`;
|
||||
default:
|
||||
util.assertNever(version);
|
||||
}
|
||||
}
|
||||
|
||||
const CHECK_ACTION_VERSION_TESTS: Array<[string, util.GitHubVersion, boolean]> =
|
||||
[
|
||||
["1.2.1", { type: util.GitHubVariant.DOTCOM }, true],
|
||||
@@ -416,7 +429,7 @@ for (const [
|
||||
const reportWarningDescription = shouldReportWarning
|
||||
? "reports warning"
|
||||
: "doesn't report warning";
|
||||
const versionsDescription = `CodeQL Action version ${version} and GitHub version ${util.formatGitHubVersion(
|
||||
const versionsDescription = `CodeQL Action version ${version} and GitHub version ${formatGitHubVersion(
|
||||
githubVersion
|
||||
)}`;
|
||||
test(`checkActionVersion ${reportWarningDescription} for ${versionsDescription}`, async (t) => {
|
||||
|
||||
-13
@@ -738,16 +738,3 @@ export async function checkActionVersion(version: string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function formatGitHubVersion(version: GitHubVersion): string {
|
||||
switch (version.type) {
|
||||
case GitHubVariant.DOTCOM:
|
||||
return "dotcom";
|
||||
case GitHubVariant.GHAE:
|
||||
return "GHAE";
|
||||
case GitHubVariant.GHES:
|
||||
return `GHES ${version.version}`;
|
||||
default:
|
||||
assertNever(version);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user