Loading __tests__/actionUtils.test.ts +15 Changes for __tests__/actionUtils.test.ts: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ beforeAll(() => { afterEach(() => { delete process.env[Events.Key]; delete process.env[RefKey]; testUtils.clearInputs(); }); test("isGhes returns true if server url is not github.com", () => { Loading Loading @@ -212,3 +213,17 @@ test("getInputAsArray handles empty lines correctly", () => { testUtils.setInput("foo", "\n\nbar\n\nbaz\n\n"); expect(actionUtils.getInputAsArray("foo")).toEqual(["bar", "baz"]); }); test("getInputAsInt returns undefined if input not set", () => { expect(actionUtils.getInputAsInt("foo")).toBeUndefined(); }); test("getInputAsInt returns value if input is valid", () => { testUtils.setInput("foo", "8"); expect(actionUtils.getInputAsInt("foo")).toBe(8); }); test("getInputAsInt returns undefined if input is invalid or NaN", () => { testUtils.setInput("foo", "bar"); expect(actionUtils.getInputAsInt("foo")).toBeUndefined(); }); __tests__/save.test.ts +27 −4 Changes for __tests__/save.test.ts: 27 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -27,6 +27,14 @@ beforeAll(() => { } ); jest.spyOn(actionUtils, "getInputAsInt").mockImplementation( (name, options) => { return jest .requireActual("../src/utils/actionUtils") .getInputAsInt(name, options); } ); jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation( (key, cacheResult) => { return jest Loading Loading @@ -193,7 +201,11 @@ test("save with large cache outputs warning", async () => { await run(); expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey); expect(saveCacheMock).toHaveBeenCalledWith( [inputPath], primaryKey, expect.anything() ); expect(logWarningMock).toHaveBeenCalledTimes(1); expect(logWarningMock).toHaveBeenCalledWith( Loading Loading @@ -236,7 +248,11 @@ test("save with reserve cache failure outputs warning", async () => { await run(); expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey); expect(saveCacheMock).toHaveBeenCalledWith( [inputPath], primaryKey, expect.anything() ); expect(infoMock).toHaveBeenCalledWith( `Unable to reserve cache with key ${primaryKey}, another job may be creating this cache.` Loading Loading @@ -274,7 +290,11 @@ test("save with server error outputs warning", async () => { await run(); expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey); expect(saveCacheMock).toHaveBeenCalledWith( [inputPath], primaryKey, expect.anything() ); expect(logWarningMock).toHaveBeenCalledTimes(1); expect(logWarningMock).toHaveBeenCalledWith("HTTP Error Occurred"); Loading @@ -300,6 +320,7 @@ test("save with valid inputs uploads a cache", async () => { const inputPath = "node_modules"; testUtils.setInput(Inputs.Path, inputPath); testUtils.setInput(Inputs.UploadChunkSize, "4000000"); const cacheId = 4; const saveCacheMock = jest Loading @@ -311,7 +332,9 @@ test("save with valid inputs uploads a cache", async () => { await run(); expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, { uploadChunkSize: 4000000 }); expect(failedMock).toHaveBeenCalledTimes(0); }); dist/restore/index.js +10 −1 Changes for dist/restore/index.js: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -31296,7 +31296,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(694); function isGhes() { Loading Loading @@ -31353,6 +31353,14 @@ function getInputAsArray(name, options) { .filter(x => x !== ""); } exports.getInputAsArray = getInputAsArray; function getInputAsInt(name, options) { const value = Number(core.getInput(name, options)); if (Number.isNaN(value) || value < 0) { return undefined; } return value; } exports.getInputAsInt = getInputAsInt; /***/ }), Loading Loading @@ -38485,6 +38493,7 @@ var Inputs; Inputs["Key"] = "key"; Inputs["Path"] = "path"; Inputs["RestoreKeys"] = "restore-keys"; Inputs["UploadChunkSize"] = "upload-chunk-size"; })(Inputs = exports.Inputs || (exports.Inputs = {})); var Outputs; (function (Outputs) { dist/save/index.js +13 −2 Changes for dist/save/index.js: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -31296,7 +31296,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(694); function isGhes() { Loading Loading @@ -31353,6 +31353,14 @@ function getInputAsArray(name, options) { .filter(x => x !== ""); } exports.getInputAsArray = getInputAsArray; function getInputAsInt(name, options) { const value = Number(core.getInput(name, options)); if (Number.isNaN(value) || value < 0) { return undefined; } return value; } exports.getInputAsInt = getInputAsInt; /***/ }), Loading Loading @@ -38353,7 +38361,9 @@ function run() { required: true }); try { yield cache.saveCache(cachePaths, primaryKey); yield cache.saveCache(cachePaths, primaryKey, { uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) }); } catch (error) { if (error.name === cache.ValidationError.name) { Loading Loading @@ -38574,6 +38584,7 @@ var Inputs; Inputs["Key"] = "key"; Inputs["Path"] = "path"; Inputs["RestoreKeys"] = "restore-keys"; Inputs["UploadChunkSize"] = "upload-chunk-size"; })(Inputs = exports.Inputs || (exports.Inputs = {})); var Outputs; (function (Outputs) { package-lock.json +1 −1 Changes for package-lock.json: 1 added line, 1 removed line. Original line number Diff line number Diff line { "name": "cache", "version": "2.1.1", "version": "2.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { Loading Loading
__tests__/actionUtils.test.ts +15 Changes for __tests__/actionUtils.test.ts: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ beforeAll(() => { afterEach(() => { delete process.env[Events.Key]; delete process.env[RefKey]; testUtils.clearInputs(); }); test("isGhes returns true if server url is not github.com", () => { Loading Loading @@ -212,3 +213,17 @@ test("getInputAsArray handles empty lines correctly", () => { testUtils.setInput("foo", "\n\nbar\n\nbaz\n\n"); expect(actionUtils.getInputAsArray("foo")).toEqual(["bar", "baz"]); }); test("getInputAsInt returns undefined if input not set", () => { expect(actionUtils.getInputAsInt("foo")).toBeUndefined(); }); test("getInputAsInt returns value if input is valid", () => { testUtils.setInput("foo", "8"); expect(actionUtils.getInputAsInt("foo")).toBe(8); }); test("getInputAsInt returns undefined if input is invalid or NaN", () => { testUtils.setInput("foo", "bar"); expect(actionUtils.getInputAsInt("foo")).toBeUndefined(); });
__tests__/save.test.ts +27 −4 Changes for __tests__/save.test.ts: 27 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -27,6 +27,14 @@ beforeAll(() => { } ); jest.spyOn(actionUtils, "getInputAsInt").mockImplementation( (name, options) => { return jest .requireActual("../src/utils/actionUtils") .getInputAsInt(name, options); } ); jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation( (key, cacheResult) => { return jest Loading Loading @@ -193,7 +201,11 @@ test("save with large cache outputs warning", async () => { await run(); expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey); expect(saveCacheMock).toHaveBeenCalledWith( [inputPath], primaryKey, expect.anything() ); expect(logWarningMock).toHaveBeenCalledTimes(1); expect(logWarningMock).toHaveBeenCalledWith( Loading Loading @@ -236,7 +248,11 @@ test("save with reserve cache failure outputs warning", async () => { await run(); expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey); expect(saveCacheMock).toHaveBeenCalledWith( [inputPath], primaryKey, expect.anything() ); expect(infoMock).toHaveBeenCalledWith( `Unable to reserve cache with key ${primaryKey}, another job may be creating this cache.` Loading Loading @@ -274,7 +290,11 @@ test("save with server error outputs warning", async () => { await run(); expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey); expect(saveCacheMock).toHaveBeenCalledWith( [inputPath], primaryKey, expect.anything() ); expect(logWarningMock).toHaveBeenCalledTimes(1); expect(logWarningMock).toHaveBeenCalledWith("HTTP Error Occurred"); Loading @@ -300,6 +320,7 @@ test("save with valid inputs uploads a cache", async () => { const inputPath = "node_modules"; testUtils.setInput(Inputs.Path, inputPath); testUtils.setInput(Inputs.UploadChunkSize, "4000000"); const cacheId = 4; const saveCacheMock = jest Loading @@ -311,7 +332,9 @@ test("save with valid inputs uploads a cache", async () => { await run(); expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey); expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, { uploadChunkSize: 4000000 }); expect(failedMock).toHaveBeenCalledTimes(0); });
dist/restore/index.js +10 −1 Changes for dist/restore/index.js: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -31296,7 +31296,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(694); function isGhes() { Loading Loading @@ -31353,6 +31353,14 @@ function getInputAsArray(name, options) { .filter(x => x !== ""); } exports.getInputAsArray = getInputAsArray; function getInputAsInt(name, options) { const value = Number(core.getInput(name, options)); if (Number.isNaN(value) || value < 0) { return undefined; } return value; } exports.getInputAsInt = getInputAsInt; /***/ }), Loading Loading @@ -38485,6 +38493,7 @@ var Inputs; Inputs["Key"] = "key"; Inputs["Path"] = "path"; Inputs["RestoreKeys"] = "restore-keys"; Inputs["UploadChunkSize"] = "upload-chunk-size"; })(Inputs = exports.Inputs || (exports.Inputs = {})); var Outputs; (function (Outputs) {
dist/save/index.js +13 −2 Changes for dist/save/index.js: 13 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -31296,7 +31296,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = exports.isGhes = void 0; const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(694); function isGhes() { Loading Loading @@ -31353,6 +31353,14 @@ function getInputAsArray(name, options) { .filter(x => x !== ""); } exports.getInputAsArray = getInputAsArray; function getInputAsInt(name, options) { const value = Number(core.getInput(name, options)); if (Number.isNaN(value) || value < 0) { return undefined; } return value; } exports.getInputAsInt = getInputAsInt; /***/ }), Loading Loading @@ -38353,7 +38361,9 @@ function run() { required: true }); try { yield cache.saveCache(cachePaths, primaryKey); yield cache.saveCache(cachePaths, primaryKey, { uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) }); } catch (error) { if (error.name === cache.ValidationError.name) { Loading Loading @@ -38574,6 +38584,7 @@ var Inputs; Inputs["Key"] = "key"; Inputs["Path"] = "path"; Inputs["RestoreKeys"] = "restore-keys"; Inputs["UploadChunkSize"] = "upload-chunk-size"; })(Inputs = exports.Inputs || (exports.Inputs = {})); var Outputs; (function (Outputs) {
package-lock.json +1 −1 Changes for package-lock.json: 1 added line, 1 removed line. Original line number Diff line number Diff line { "name": "cache", "version": "2.1.1", "version": "2.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { Loading