Skip to content

Commit 4284df4

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 8a5a8b7 + 0c45773 commit 4284df4

File tree

7 files changed

+39
-32
lines changed

7 files changed

+39
-32
lines changed

RELEASES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
### 4.0.2
4+
5+
- Fixed restore `fail-on-cache-miss` not working.
6+
37
### 4.0.1
48

59
- Updated `isGhes` check

__tests__/restoreImpl.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,19 @@ test("restore with lookup-only set", async () => {
449449
);
450450
expect(failedMock).toHaveBeenCalledTimes(0);
451451
});
452+
453+
test("restore failure with earlyExit should call process exit", async () => {
454+
testUtils.setInput(Inputs.Path, "node_modules");
455+
const failedMock = jest.spyOn(core, "setFailed");
456+
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
457+
const processExitMock = jest.spyOn(process, "exit").mockImplementation();
458+
459+
// call restoreImpl with `earlyExit` set to true
460+
await restoreImpl(new StateProvider(), true);
461+
462+
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
463+
expect(failedMock).toHaveBeenCalledWith(
464+
"Input required and not supplied: key"
465+
);
466+
expect(processExitMock).toHaveBeenCalledWith(1);
467+
});

dist/restore-only/index.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94935,7 +94935,7 @@ const stateProvider_1 = __nccwpck_require__(1527);
9493594935
const utils = __importStar(__nccwpck_require__(4427));
9493694936
const restore = __importStar(__nccwpck_require__(8486));
9493794937
const install = __importStar(__nccwpck_require__(8501));
94938-
function restoreImpl(stateProvider) {
94938+
function restoreImpl(stateProvider, earlyExit) {
9493994939
var _a, _b, _c, _d, _e, _f, _g;
9494094940
return __awaiter(this, void 0, void 0, function* () {
9494194941
try {
@@ -95041,21 +95041,16 @@ function restoreImpl(stateProvider) {
9504195041
}
9504295042
catch (error) {
9504395043
core.setFailed(error.message);
95044+
if (earlyExit) {
95045+
process.exit(1);
95046+
}
9504495047
}
9504595048
});
9504695049
}
9504795050
exports.restoreImpl = restoreImpl;
9504895051
function run(stateProvider, earlyExit) {
9504995052
return __awaiter(this, void 0, void 0, function* () {
95050-
try {
95051-
yield restoreImpl(stateProvider);
95052-
}
95053-
catch (err) {
95054-
console.error(err);
95055-
if (earlyExit) {
95056-
process.exit(1);
95057-
}
95058-
}
95053+
yield restoreImpl(stateProvider, earlyExit);
9505995054
// node will stay alive if any promises are not resolved,
9506095055
// which is a possibility if HTTP requests are dangling
9506195056
// due to retries or timeouts. We know that if we got here

dist/restore/index.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94935,7 +94935,7 @@ const stateProvider_1 = __nccwpck_require__(1527);
9493594935
const utils = __importStar(__nccwpck_require__(4427));
9493694936
const restore = __importStar(__nccwpck_require__(8486));
9493794937
const install = __importStar(__nccwpck_require__(8501));
94938-
function restoreImpl(stateProvider) {
94938+
function restoreImpl(stateProvider, earlyExit) {
9493994939
var _a, _b, _c, _d, _e, _f, _g;
9494094940
return __awaiter(this, void 0, void 0, function* () {
9494194941
try {
@@ -95041,21 +95041,16 @@ function restoreImpl(stateProvider) {
9504195041
}
9504295042
catch (error) {
9504395043
core.setFailed(error.message);
95044+
if (earlyExit) {
95045+
process.exit(1);
95046+
}
9504495047
}
9504595048
});
9504695049
}
9504795050
exports.restoreImpl = restoreImpl;
9504895051
function run(stateProvider, earlyExit) {
9504995052
return __awaiter(this, void 0, void 0, function* () {
95050-
try {
95051-
yield restoreImpl(stateProvider);
95052-
}
95053-
catch (err) {
95054-
console.error(err);
95055-
if (earlyExit) {
95056-
process.exit(1);
95057-
}
95058-
}
95053+
yield restoreImpl(stateProvider, earlyExit);
9505995054
// node will stay alive if any promises are not resolved,
9506095055
// which is a possibility if HTTP requests are dangling
9506195056
// due to retries or timeouts. We know that if we got here

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cache",
3-
"version": "4.0.1",
3+
"version": "4.0.2",
44
"private": true,
55
"description": "Cache dependencies and build outputs",
66
"main": "dist/restore/index.js",

src/restoreImpl.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import * as restore from "./utils/restore";
1212
import * as install from "./utils/install";
1313

1414
export async function restoreImpl(
15-
stateProvider: IStateProvider
15+
stateProvider: IStateProvider,
16+
earlyExit?: boolean | undefined
1617
): Promise<string | undefined> {
1718
try {
1819
core.setOutput(Outputs.Hit, false);
@@ -154,21 +155,17 @@ export async function restoreImpl(
154155
return restoredKey;
155156
} catch (error: unknown) {
156157
core.setFailed((error as Error).message);
158+
if (earlyExit) {
159+
process.exit(1);
160+
}
157161
}
158162
}
159163

160164
async function run(
161165
stateProvider: IStateProvider,
162166
earlyExit: boolean | undefined
163167
): Promise<void> {
164-
try {
165-
await restoreImpl(stateProvider);
166-
} catch (err) {
167-
console.error(err);
168-
if (earlyExit) {
169-
process.exit(1);
170-
}
171-
}
168+
await restoreImpl(stateProvider, earlyExit);
172169

173170
// node will stay alive if any promises are not resolved,
174171
// which is a possibility if HTTP requests are dangling

0 commit comments

Comments
 (0)