From e29dad3e36390db18fc19fb666cb1302f4929002 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:58:25 +0100 Subject: [PATCH] Fix fail-on-cache-miss not working --- dist/restore-only/index.js | 15 +++++---------- dist/restore/index.js | 15 +++++---------- src/restoreImpl.ts | 15 ++++++--------- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index e8148ee..9a59ac0 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -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 diff --git a/dist/restore/index.js b/dist/restore/index.js index 9995844..03a12b5 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -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 diff --git a/src/restoreImpl.ts b/src/restoreImpl.ts index 0aff57a..74a366d 100644 --- a/src/restoreImpl.ts +++ b/src/restoreImpl.ts @@ -10,7 +10,8 @@ import { import * as utils from "./utils/actionUtils"; export async function restoreImpl( - stateProvider: IStateProvider + stateProvider: IStateProvider, + earlyExit?: boolean | undefined ): Promise { try { if (!utils.isCacheFeatureAvailable()) { @@ -83,6 +84,9 @@ export async function restoreImpl( return cacheKey; } catch (error: unknown) { core.setFailed((error as Error).message); + if (earlyExit) { + process.exit(1); + } } } @@ -90,14 +94,7 @@ async function run( stateProvider: IStateProvider, earlyExit: boolean | undefined ): Promise { - try { - await restoreImpl(stateProvider); - } catch (err) { - console.error(err); - if (earlyExit) { - process.exit(1); - } - } + await restoreImpl(stateProvider, earlyExit); // node will stay alive if any promises are not resolved, // which is a possibility if HTTP requests are dangling