Loading __tests__/actionUtils.test.ts +35 −1 Changes for __tests__/actionUtils.test.ts: 35 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -8,17 +8,26 @@ import * as testUtils from "../src/utils/testUtils"; jest.mock("@actions/core"); jest.mock("@actions/cache"); let pristineEnv: NodeJS.ProcessEnv; beforeAll(() => { pristineEnv = process.env; jest.spyOn(core, "getInput").mockImplementation((name, options) => { return jest.requireActual("@actions/core").getInput(name, options); }); }); afterEach(() => { beforeEach(() => { jest.resetModules(); process.env = pristineEnv; delete process.env[Events.Key]; delete process.env[RefKey]; }); afterAll(() => { process.env = pristineEnv; }); test("isGhes returns true if server url is not github.com", () => { try { process.env["GITHUB_SERVER_URL"] = "http://example.com"; Loading Loading @@ -231,3 +240,28 @@ test("isCacheFeatureAvailable for ac disabled on dotcom", () => { delete process.env["GITHUB_SERVER_URL"]; } }); test("isGhes returns false when the GITHUB_SERVER_URL environment variable is not defined", async () => { delete process.env["GITHUB_SERVER_URL"]; expect(actionUtils.isGhes()).toBeFalsy(); }); test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to github.com", async () => { process.env["GITHUB_SERVER_URL"] = "https://github.com"; expect(actionUtils.isGhes()).toBeFalsy(); }); test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL", async () => { process.env["GITHUB_SERVER_URL"] = "https://contoso.ghe.com"; expect(actionUtils.isGhes()).toBeFalsy(); }); test("isGhes returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix", async () => { process.env["GITHUB_SERVER_URL"] = "https://mock-github.localhost"; expect(actionUtils.isGhes()).toBeFalsy(); }); test("isGhes returns true when the GITHUB_SERVER_URL environment variable is set to some other URL", async () => { process.env["GITHUB_SERVER_URL"] = "https://src.onpremise.fabrikam.com"; expect(actionUtils.isGhes()).toBeTruthy(); }); dist/restore-only/index.js +5 −1 Changes for dist/restore-only/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59586,7 +59586,11 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); function isGhes() { const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === "GITHUB.COM"; const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM"); const isLocalHost = hostname.endsWith(".LOCALHOST"); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) { dist/restore/index.js +5 −1 Changes for dist/restore/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59586,7 +59586,11 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); function isGhes() { const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === "GITHUB.COM"; const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM"); const isLocalHost = hostname.endsWith(".LOCALHOST"); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) { dist/save-only/index.js +5 −1 Changes for dist/save-only/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59599,7 +59599,11 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); function isGhes() { const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === "GITHUB.COM"; const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM"); const isLocalHost = hostname.endsWith(".LOCALHOST"); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) { dist/save/index.js +5 −1 Changes for dist/save/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59599,7 +59599,11 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); function isGhes() { const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === "GITHUB.COM"; const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM"); const isLocalHost = hostname.endsWith(".LOCALHOST"); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) { Loading
__tests__/actionUtils.test.ts +35 −1 Changes for __tests__/actionUtils.test.ts: 35 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -8,17 +8,26 @@ import * as testUtils from "../src/utils/testUtils"; jest.mock("@actions/core"); jest.mock("@actions/cache"); let pristineEnv: NodeJS.ProcessEnv; beforeAll(() => { pristineEnv = process.env; jest.spyOn(core, "getInput").mockImplementation((name, options) => { return jest.requireActual("@actions/core").getInput(name, options); }); }); afterEach(() => { beforeEach(() => { jest.resetModules(); process.env = pristineEnv; delete process.env[Events.Key]; delete process.env[RefKey]; }); afterAll(() => { process.env = pristineEnv; }); test("isGhes returns true if server url is not github.com", () => { try { process.env["GITHUB_SERVER_URL"] = "http://example.com"; Loading Loading @@ -231,3 +240,28 @@ test("isCacheFeatureAvailable for ac disabled on dotcom", () => { delete process.env["GITHUB_SERVER_URL"]; } }); test("isGhes returns false when the GITHUB_SERVER_URL environment variable is not defined", async () => { delete process.env["GITHUB_SERVER_URL"]; expect(actionUtils.isGhes()).toBeFalsy(); }); test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to github.com", async () => { process.env["GITHUB_SERVER_URL"] = "https://github.com"; expect(actionUtils.isGhes()).toBeFalsy(); }); test("isGhes returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL", async () => { process.env["GITHUB_SERVER_URL"] = "https://contoso.ghe.com"; expect(actionUtils.isGhes()).toBeFalsy(); }); test("isGhes returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix", async () => { process.env["GITHUB_SERVER_URL"] = "https://mock-github.localhost"; expect(actionUtils.isGhes()).toBeFalsy(); }); test("isGhes returns true when the GITHUB_SERVER_URL environment variable is set to some other URL", async () => { process.env["GITHUB_SERVER_URL"] = "https://src.onpremise.fabrikam.com"; expect(actionUtils.isGhes()).toBeTruthy(); });
dist/restore-only/index.js +5 −1 Changes for dist/restore-only/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59586,7 +59586,11 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); function isGhes() { const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === "GITHUB.COM"; const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM"); const isLocalHost = hostname.endsWith(".LOCALHOST"); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) {
dist/restore/index.js +5 −1 Changes for dist/restore/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59586,7 +59586,11 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); function isGhes() { const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === "GITHUB.COM"; const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM"); const isLocalHost = hostname.endsWith(".LOCALHOST"); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) {
dist/save-only/index.js +5 −1 Changes for dist/save-only/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59599,7 +59599,11 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); function isGhes() { const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === "GITHUB.COM"; const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM"); const isLocalHost = hostname.endsWith(".LOCALHOST"); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) {
dist/save/index.js +5 −1 Changes for dist/save/index.js: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -59599,7 +59599,11 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); function isGhes() { const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; const hostname = ghUrl.hostname.trimEnd().toUpperCase(); const isGitHubHost = hostname === "GITHUB.COM"; const isGitHubEnterpriseCloudHost = hostname.endsWith(".GHE.COM"); const isLocalHost = hostname.endsWith(".LOCALHOST"); return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) {