mirror of
https://github.com/nick-fields/retry.git
synced 2026-02-10 07:05:29 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
943e742917 | ||
|
|
0711ba3d78 |
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@@ -16,4 +16,4 @@ A clear and concise description of what you expected to happen.
|
|||||||
If applicable, add screenshots to help explain your problem.
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
**Logs**
|
**Logs**
|
||||||
Enable [debug logging](https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging) then attach the [raw logs](https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs) (specifically the raw output of this action).
|
Enable [debug logging](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging) then attach the [raw logs](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/using-workflow-run-logs#downloading-logs) (specifically the raw output of this action).
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ Retries an Action step on failure or timeout. This is currently intended to repl
|
|||||||
|
|
||||||
### `shell`
|
### `shell`
|
||||||
|
|
||||||
**Optional** Shell to use to execute `command`. Defaults to `powershell` on Windows, `bash` otherwise. Supports bash, python, pwsh, sh, cmd, and powershell per [docs](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell)
|
**Optional** Shell to use to execute `command`. Defaults to `powershell` on Windows, `bash` otherwise. Supports bash, python, pwsh, sh, cmd, and powershell per [docs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell)
|
||||||
|
|
||||||
### `polling_interval_seconds`
|
### `polling_interval_seconds`
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ with:
|
|||||||
```yaml
|
```yaml
|
||||||
- uses: nick-fields/retry@v2
|
- uses: nick-fields/retry@v2
|
||||||
id: retry
|
id: retry
|
||||||
# see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error
|
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
timeout_seconds: 15
|
timeout_seconds: 15
|
||||||
|
|||||||
16
dist/index.js
vendored
16
dist/index.js
vendored
@@ -971,7 +971,7 @@ function getExecutable(inputs) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error("Shell ".concat(inputs.shell, " not supported. See https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell for supported shells"));
|
throw new Error("Shell ".concat(inputs.shell, " not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return executable;
|
return executable;
|
||||||
@@ -1005,7 +1005,7 @@ function runRetryCmd(inputs) {
|
|||||||
function runCmd(attempt, inputs) {
|
function runCmd(attempt, inputs) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var end_time, executable, child;
|
var end_time, executable, timeout, child;
|
||||||
return __generator(this, function (_c) {
|
return __generator(this, function (_c) {
|
||||||
switch (_c.label) {
|
switch (_c.label) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -1013,6 +1013,7 @@ function runCmd(attempt, inputs) {
|
|||||||
executable = getExecutable(inputs);
|
executable = getExecutable(inputs);
|
||||||
exit = 0;
|
exit = 0;
|
||||||
done = false;
|
done = false;
|
||||||
|
timeout = false;
|
||||||
(0, core_1.debug)("Running command ".concat(inputs.command, " on ").concat(OS, " using shell ").concat(executable));
|
(0, core_1.debug)("Running command ".concat(inputs.command, " on ").concat(OS, " using shell ").concat(executable));
|
||||||
child = attempt > 1 && inputs.new_command_on_retry
|
child = attempt > 1 && inputs.new_command_on_retry
|
||||||
? (0, child_process_1.spawn)(inputs.new_command_on_retry, { shell: executable })
|
? (0, child_process_1.spawn)(inputs.new_command_on_retry, { shell: executable })
|
||||||
@@ -1026,13 +1027,17 @@ function runCmd(attempt, inputs) {
|
|||||||
child.on('exit', function (code, signal) {
|
child.on('exit', function (code, signal) {
|
||||||
(0, core_1.debug)("Code: ".concat(code));
|
(0, core_1.debug)("Code: ".concat(code));
|
||||||
(0, core_1.debug)("Signal: ".concat(signal));
|
(0, core_1.debug)("Signal: ".concat(signal));
|
||||||
if (code && code > 0) {
|
|
||||||
exit = code;
|
|
||||||
}
|
|
||||||
// timeouts are killed manually
|
// timeouts are killed manually
|
||||||
if (signal === 'SIGTERM') {
|
if (signal === 'SIGTERM') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// On Windows signal is null.
|
||||||
|
if (timeout) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (code && code > 0) {
|
||||||
|
exit = code;
|
||||||
|
}
|
||||||
done = true;
|
done = true;
|
||||||
});
|
});
|
||||||
_c.label = 1;
|
_c.label = 1;
|
||||||
@@ -1045,6 +1050,7 @@ function runCmd(attempt, inputs) {
|
|||||||
_c.label = 4;
|
_c.label = 4;
|
||||||
case 4:
|
case 4:
|
||||||
if (!(!done && child.pid)) return [3 /*break*/, 6];
|
if (!(!done && child.pid)) return [3 /*break*/, 6];
|
||||||
|
timeout = true;
|
||||||
(0, tree_kill_1.default)(child.pid);
|
(0, tree_kill_1.default)(child.pid);
|
||||||
return [4 /*yield*/, (0, util_1.retryWait)(milliseconds_1.default.seconds(inputs.retry_wait_seconds))];
|
return [4 /*yield*/, (0, util_1.retryWait)(milliseconds_1.default.seconds(inputs.retry_wait_seconds))];
|
||||||
case 5:
|
case 5:
|
||||||
|
|||||||
18
src/index.ts
18
src/index.ts
@@ -44,7 +44,7 @@ function getExecutable(inputs: Inputs): string {
|
|||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Shell ${inputs.shell} not supported. See https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell for supported shells`
|
`Shell ${inputs.shell} not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,6 +71,7 @@ async function runCmd(attempt: number, inputs: Inputs) {
|
|||||||
|
|
||||||
exit = 0;
|
exit = 0;
|
||||||
done = false;
|
done = false;
|
||||||
|
let timeout = false;
|
||||||
|
|
||||||
debug(`Running command ${inputs.command} on ${OS} using shell ${executable}`);
|
debug(`Running command ${inputs.command} on ${OS} using shell ${executable}`);
|
||||||
const child =
|
const child =
|
||||||
@@ -88,13 +89,21 @@ async function runCmd(attempt: number, inputs: Inputs) {
|
|||||||
child.on('exit', (code, signal) => {
|
child.on('exit', (code, signal) => {
|
||||||
debug(`Code: ${code}`);
|
debug(`Code: ${code}`);
|
||||||
debug(`Signal: ${signal}`);
|
debug(`Signal: ${signal}`);
|
||||||
if (code && code > 0) {
|
|
||||||
exit = code;
|
|
||||||
}
|
|
||||||
// timeouts are killed manually
|
// timeouts are killed manually
|
||||||
if (signal === 'SIGTERM') {
|
if (signal === 'SIGTERM') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On Windows signal is null.
|
||||||
|
if (timeout) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code && code > 0) {
|
||||||
|
exit = code;
|
||||||
|
}
|
||||||
|
|
||||||
done = true;
|
done = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,6 +112,7 @@ async function runCmd(attempt: number, inputs: Inputs) {
|
|||||||
} while (Date.now() < end_time && !done);
|
} while (Date.now() < end_time && !done);
|
||||||
|
|
||||||
if (!done && child.pid) {
|
if (!done && child.pid) {
|
||||||
|
timeout = true;
|
||||||
kill(child.pid);
|
kill(child.pid);
|
||||||
await retryWait(ms.seconds(inputs.retry_wait_seconds));
|
await retryWait(ms.seconds(inputs.retry_wait_seconds));
|
||||||
throw new Error(`Timeout of ${getTimeout(inputs)}ms hit`);
|
throw new Error(`Timeout of ${getTimeout(inputs)}ms hit`);
|
||||||
|
|||||||
Reference in New Issue
Block a user