Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(retry): uses same shell #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 19 additions & 27 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -979,27 +979,19 @@ function getExecutable(inputs) {
}
function runRetryCmd(inputs) {
return __awaiter(this, void 0, void 0, function () {
var error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// if no retry script, just continue
if (!inputs.on_retry_command) {
return [2 /*return*/];
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, (0, child_process_1.execSync)(inputs.on_retry_command, { stdio: 'inherit' })];
case 2:
_a.sent();
return [3 /*break*/, 4];
case 3:
error_1 = _a.sent();
(0, core_1.info)("WARNING: Retry command threw the error ".concat(error_1.message));
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
// if no retry script, just continue
if (!inputs.on_retry_command) {
return [2 /*return*/];
}
try {
(0, child_process_1.execSync)(inputs.on_retry_command, { stdio: 'inherit', shell: getExecutable(inputs) });
// eslint-disable-next-line
}
catch (error) {
(0, core_1.info)("WARNING: Retry command threw the error ".concat(error.message));
}
return [2 /*return*/];
});
});
}
Expand Down Expand Up @@ -1070,7 +1062,7 @@ function runCmd(attempt, inputs) {
}
function runAction(inputs) {
return __awaiter(this, void 0, void 0, function () {
var attempt, error_2;
var attempt, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, inputs_1.validateInputs)(inputs)];
Expand All @@ -1091,28 +1083,28 @@ function runAction(inputs) {
(0, core_1.info)("Command completed after ".concat(attempt, " attempt(s)."));
return [3 /*break*/, 13];
case 5:
error_2 = _a.sent();
error_1 = _a.sent();
if (!(attempt === inputs.max_attempts)) return [3 /*break*/, 6];
throw new Error("Final attempt failed. ".concat(error_2.message));
throw new Error("Final attempt failed. ".concat(error_1.message));
case 6:
if (!(!done && inputs.retry_on === 'error')) return [3 /*break*/, 7];
// error: timeout
throw error_2;
throw error_1;
case 7:
if (!(inputs.retry_on_exit_code && inputs.retry_on_exit_code !== exit)) return [3 /*break*/, 8];
throw error_2;
throw error_1;
case 8:
if (!(exit > 0 && inputs.retry_on === 'timeout')) return [3 /*break*/, 9];
// error: error
throw error_2;
throw error_1;
case 9: return [4 /*yield*/, runRetryCmd(inputs)];
case 10:
_a.sent();
if (inputs.warning_on_retry) {
(0, core_1.warning)("Attempt ".concat(attempt, " failed. Reason: ").concat(error_2.message));
(0, core_1.warning)("Attempt ".concat(attempt, " failed. Reason: ").concat(error_1.message));
}
else {
(0, core_1.info)("Attempt ".concat(attempt, " failed. Reason: ").concat(error_2.message));
(0, core_1.info)("Attempt ".concat(attempt, " failed. Reason: ").concat(error_1.message));
}
_a.label = 11;
case 11: return [3 /*break*/, 12];
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function runRetryCmd(inputs: Inputs): Promise<void> {
}

try {
await execSync(inputs.on_retry_command, { stdio: 'inherit' });
execSync(inputs.on_retry_command, { stdio: 'inherit', shell: getExecutable(inputs) });
// eslint-disable-next-line
} catch (error: any) {
info(`WARNING: Retry command threw the error ${error.message}`);
Expand Down
Loading