Loading __tests__/restore.test.ts +24 Changes for __tests__/restore.test.ts: 24 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -53,6 +53,30 @@ test("restore with invalid event outputs warning", async () => { expect(failedMock).toHaveBeenCalledTimes(0); }); test("restore on GHES should no-op", async () => { try { process.env["GITHUB_SERVER_URL"] = "http://example.com"; const infoMock = jest.spyOn(core, "info"); const restoreCacheMock = jest.spyOn(cache, "restoreCache"); const setCacheHitOutputMock = jest.spyOn( actionUtils, "setCacheHitOutput" ); await run(); expect(restoreCacheMock).toHaveBeenCalledTimes(0); expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setCacheHitOutputMock).toHaveBeenCalledWith(false); expect(infoMock).toHaveBeenCalledWith( "Cache action is not supported on GHES" ); } finally { process.env["GITHUB_SERVER_URL"] = undefined; } }); test("restore with no path should fail", async () => { const failedMock = jest.spyOn(core, "setFailed"); const restoreCacheMock = jest.spyOn(cache, "restoreCache"); Loading __tests__/save.test.ts +18 Changes for __tests__/save.test.ts: 18 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -91,6 +91,24 @@ test("save with no primary key in state outputs warning", async () => { expect(failedMock).toHaveBeenCalledTimes(0); }); test("save on GHES should no-op", async () => { try { process.env["GITHUB_SERVER_URL"] = "http://example.com"; const infoMock = jest.spyOn(core, "info"); const saveCacheMock = jest.spyOn(cache, "saveCache"); await run(); expect(saveCacheMock).toHaveBeenCalledTimes(0); expect(infoMock).toHaveBeenCalledWith( "Cache action is not supported on GHES" ); } finally { process.env["GITHUB_SERVER_URL"] = undefined; } }); test("save with exact match returns early", async () => { const infoMock = jest.spyOn(core, "info"); const failedMock = jest.spyOn(core, "setFailed"); Loading src/restore.ts +6 Changes for src/restore.ts: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,12 @@ import * as utils from "./utils/actionUtils"; async function run(): Promise<void> { try { if (utils.isGhes()) { core.info("Cache action is not supported on GHES"); utils.setCacheHitOutput(false); return; } // Validate inputs, this can cause task failure if (!utils.isValidEvent()) { utils.logWarning( Loading src/save.ts +5 Changes for src/save.ts: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,11 @@ import * as utils from "./utils/actionUtils"; async function run(): Promise<void> { try { if (utils.isGhes()) { core.info("Cache action is not supported on GHES"); return; } if (!utils.isValidEvent()) { utils.logWarning( `Event Validation Error: The event type ${ Loading src/utils/actionUtils.ts +7 Changes for src/utils/actionUtils.ts: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,13 @@ import * as core from "@actions/core"; import { Outputs, RefKey, State } from "../constants"; export function isGhes(): boolean { const ghUrl = new URL( process.env["GITHUB_SERVER_URL"] || "https://github.com" ); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; } export function isExactKeyMatch(key: string, cacheKey?: string): boolean { return !!( cacheKey && Loading Loading
__tests__/restore.test.ts +24 Changes for __tests__/restore.test.ts: 24 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -53,6 +53,30 @@ test("restore with invalid event outputs warning", async () => { expect(failedMock).toHaveBeenCalledTimes(0); }); test("restore on GHES should no-op", async () => { try { process.env["GITHUB_SERVER_URL"] = "http://example.com"; const infoMock = jest.spyOn(core, "info"); const restoreCacheMock = jest.spyOn(cache, "restoreCache"); const setCacheHitOutputMock = jest.spyOn( actionUtils, "setCacheHitOutput" ); await run(); expect(restoreCacheMock).toHaveBeenCalledTimes(0); expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setCacheHitOutputMock).toHaveBeenCalledWith(false); expect(infoMock).toHaveBeenCalledWith( "Cache action is not supported on GHES" ); } finally { process.env["GITHUB_SERVER_URL"] = undefined; } }); test("restore with no path should fail", async () => { const failedMock = jest.spyOn(core, "setFailed"); const restoreCacheMock = jest.spyOn(cache, "restoreCache"); Loading
__tests__/save.test.ts +18 Changes for __tests__/save.test.ts: 18 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -91,6 +91,24 @@ test("save with no primary key in state outputs warning", async () => { expect(failedMock).toHaveBeenCalledTimes(0); }); test("save on GHES should no-op", async () => { try { process.env["GITHUB_SERVER_URL"] = "http://example.com"; const infoMock = jest.spyOn(core, "info"); const saveCacheMock = jest.spyOn(cache, "saveCache"); await run(); expect(saveCacheMock).toHaveBeenCalledTimes(0); expect(infoMock).toHaveBeenCalledWith( "Cache action is not supported on GHES" ); } finally { process.env["GITHUB_SERVER_URL"] = undefined; } }); test("save with exact match returns early", async () => { const infoMock = jest.spyOn(core, "info"); const failedMock = jest.spyOn(core, "setFailed"); Loading
src/restore.ts +6 Changes for src/restore.ts: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,12 @@ import * as utils from "./utils/actionUtils"; async function run(): Promise<void> { try { if (utils.isGhes()) { core.info("Cache action is not supported on GHES"); utils.setCacheHitOutput(false); return; } // Validate inputs, this can cause task failure if (!utils.isValidEvent()) { utils.logWarning( Loading
src/save.ts +5 Changes for src/save.ts: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,11 @@ import * as utils from "./utils/actionUtils"; async function run(): Promise<void> { try { if (utils.isGhes()) { core.info("Cache action is not supported on GHES"); return; } if (!utils.isValidEvent()) { utils.logWarning( `Event Validation Error: The event type ${ Loading
src/utils/actionUtils.ts +7 Changes for src/utils/actionUtils.ts: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,13 @@ import * as core from "@actions/core"; import { Outputs, RefKey, State } from "../constants"; export function isGhes(): boolean { const ghUrl = new URL( process.env["GITHUB_SERVER_URL"] || "https://github.com" ); return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; } export function isExactKeyMatch(key: string, cacheKey?: string): boolean { return !!( cacheKey && Loading