Unverified Commit 0c45773b authored by Bethany's avatar Bethany Committed by GitHub
Browse files

Merge pull request #1327 from cdce8p/fix-fail-on-cache-miss

Fix `fail-on-cache-miss` not working
parents ab5e6d0c 8a55f839
Loading
Loading
Loading
Loading
+4
Changes for RELEASES.md: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Releases

### 4.0.2

- Fixed restore `fail-on-cache-miss` not working.

### 4.0.1

- Updated `isGhes` check
+16
Changes for __tests__/restoreImpl.test.ts: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -449,3 +449,19 @@ test("restore with lookup-only set", async () => {
    );
    expect(failedMock).toHaveBeenCalledTimes(0);
});

test("restore failure with earlyExit should call process exit", async () => {
    testUtils.setInput(Inputs.Path, "node_modules");
    const failedMock = jest.spyOn(core, "setFailed");
    const restoreCacheMock = jest.spyOn(cache, "restoreCache");
    const processExitMock = jest.spyOn(process, "exit").mockImplementation();

    // call restoreImpl with `earlyExit` set to true
    await restoreImpl(new StateProvider(), true);

    expect(restoreCacheMock).toHaveBeenCalledTimes(0);
    expect(failedMock).toHaveBeenCalledWith(
        "Input required and not supplied: key"
    );
    expect(processExitMock).toHaveBeenCalledWith(1);
});
+5 −10
Changes for dist/restore-only/index.js: 5 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -59392,7 +59392,7 @@ const core = __importStar(__nccwpck_require__(2186));
const constants_1 = __nccwpck_require__(9042);
const stateProvider_1 = __nccwpck_require__(1527);
const utils = __importStar(__nccwpck_require__(6850));
function restoreImpl(stateProvider) {
function restoreImpl(stateProvider, earlyExit) {
    return __awaiter(this, void 0, void 0, function* () {
        try {
            if (!utils.isCacheFeatureAvailable()) {
@@ -59438,21 +59438,16 @@ function restoreImpl(stateProvider) {
        }
        catch (error) {
            core.setFailed(error.message);
            if (earlyExit) {
                process.exit(1);
            }
        }
    });
}
exports.restoreImpl = restoreImpl;
function run(stateProvider, earlyExit) {
    return __awaiter(this, void 0, void 0, function* () {
        try {
            yield restoreImpl(stateProvider);
        }
        catch (err) {
            console.error(err);
            if (earlyExit) {
                process.exit(1);
            }
        }
        yield restoreImpl(stateProvider, earlyExit);
        // node will stay alive if any promises are not resolved,
        // which is a possibility if HTTP requests are dangling
        // due to retries or timeouts. We know that if we got here
+5 −10
Changes for dist/restore/index.js: 5 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -59392,7 +59392,7 @@ const core = __importStar(__nccwpck_require__(2186));
const constants_1 = __nccwpck_require__(9042);
const stateProvider_1 = __nccwpck_require__(1527);
const utils = __importStar(__nccwpck_require__(6850));
function restoreImpl(stateProvider) {
function restoreImpl(stateProvider, earlyExit) {
    return __awaiter(this, void 0, void 0, function* () {
        try {
            if (!utils.isCacheFeatureAvailable()) {
@@ -59438,21 +59438,16 @@ function restoreImpl(stateProvider) {
        }
        catch (error) {
            core.setFailed(error.message);
            if (earlyExit) {
                process.exit(1);
            }
        }
    });
}
exports.restoreImpl = restoreImpl;
function run(stateProvider, earlyExit) {
    return __awaiter(this, void 0, void 0, function* () {
        try {
            yield restoreImpl(stateProvider);
        }
        catch (err) {
            console.error(err);
            if (earlyExit) {
                process.exit(1);
            }
        }
        yield restoreImpl(stateProvider, earlyExit);
        // node will stay alive if any promises are not resolved,
        // which is a possibility if HTTP requests are dangling
        // due to retries or timeouts. We know that if we got here
+2 −2
Changes for package-lock.json: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
{
  "name": "cache",
  "version": "4.0.1",
  "version": "4.0.2",
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": {
      "name": "cache",
      "version": "4.0.1",
      "version": "4.0.2",
      "license": "MIT",
      "dependencies": {
        "@actions/cache": "^3.2.3",
Loading