mirror of
https://github.com/nick-fields/retry.git
synced 2026-02-10 23:25:28 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb3bca3fb5 | ||
|
|
51e29ff1ae | ||
|
|
292d515fa9 | ||
|
|
5ee366655c |
10
README.md
10
README.md
@@ -6,7 +6,11 @@ Retries an Action step on failure or timeout. This is currently intended to repl
|
|||||||
|
|
||||||
### `timeout_minutes`
|
### `timeout_minutes`
|
||||||
|
|
||||||
**Required** Minutes to wait before attempt times out
|
**Required** Minutes to wait before attempt times out. Must only specify either minutes or seconds
|
||||||
|
|
||||||
|
### `timeout_seconds`
|
||||||
|
|
||||||
|
**Required** Seconds to wait before attempt times out. Must only specify either minutes or seconds
|
||||||
|
|
||||||
### `max_attempts`
|
### `max_attempts`
|
||||||
|
|
||||||
@@ -28,6 +32,10 @@ Retries an Action step on failure or timeout. This is currently intended to repl
|
|||||||
|
|
||||||
**Optional** Event to retry on. Currently supports [any (default), timeout, error].
|
**Optional** Event to retry on. Currently supports [any (default), timeout, error].
|
||||||
|
|
||||||
|
### `warning_on_retry`
|
||||||
|
|
||||||
|
**Optional** Whether to output a warning on retry, or just output to info. Defaults to `true`.
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
### `total_attempts`
|
### `total_attempts`
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ inputs:
|
|||||||
default: 1
|
default: 1
|
||||||
retry_on:
|
retry_on:
|
||||||
description: Event to retry on. Currently supported [any, timeout, error]
|
description: Event to retry on. Currently supported [any, timeout, error]
|
||||||
|
warning_on_retry:
|
||||||
|
description: Whether to output a warning on retry, or just output to info. Defaults to true
|
||||||
|
default: true
|
||||||
outputs:
|
outputs:
|
||||||
total_attempts:
|
total_attempts:
|
||||||
description: The final number of attempts made
|
description: The final number of attempts made
|
||||||
|
|||||||
9
dist/index.js
vendored
9
dist/index.js
vendored
@@ -251,6 +251,7 @@ var COMMAND = core_1.getInput('command', { required: true });
|
|||||||
var RETRY_WAIT_SECONDS = getInputNumber('retry_wait_seconds', false) || 10;
|
var RETRY_WAIT_SECONDS = getInputNumber('retry_wait_seconds', false) || 10;
|
||||||
var POLLING_INTERVAL_SECONDS = getInputNumber('polling_interval_seconds', false) || 1;
|
var POLLING_INTERVAL_SECONDS = getInputNumber('polling_interval_seconds', false) || 1;
|
||||||
var RETRY_ON = core_1.getInput('retry_on') || 'any';
|
var RETRY_ON = core_1.getInput('retry_on') || 'any';
|
||||||
|
var WARNING_ON_RETRY = core_1.getInput('warning_on_retry').toLowerCase() === 'true';
|
||||||
var OUTPUT_TOTAL_ATTEMPTS_KEY = 'total_attempts';
|
var OUTPUT_TOTAL_ATTEMPTS_KEY = 'total_attempts';
|
||||||
var OUTPUT_EXIT_CODE_KEY = 'exit_code';
|
var OUTPUT_EXIT_CODE_KEY = 'exit_code';
|
||||||
var OUTPUT_EXIT_ERROR_KEY = 'exit_error';
|
var OUTPUT_EXIT_ERROR_KEY = 'exit_error';
|
||||||
@@ -291,9 +292,6 @@ function validateInputs() {
|
|||||||
if ((!TIMEOUT_MINUTES && !TIMEOUT_SECONDS) || (TIMEOUT_MINUTES && TIMEOUT_SECONDS)) {
|
if ((!TIMEOUT_MINUTES && !TIMEOUT_SECONDS) || (TIMEOUT_MINUTES && TIMEOUT_SECONDS)) {
|
||||||
throw new Error('Must specify either timeout_minutes or timeout_seconds inputs');
|
throw new Error('Must specify either timeout_minutes or timeout_seconds inputs');
|
||||||
}
|
}
|
||||||
if (TIMEOUT_SECONDS && TIMEOUT_SECONDS < RETRY_WAIT_SECONDS) {
|
|
||||||
throw new Error("timeout_seconds " + TIMEOUT_SECONDS + "s less than retry_wait_seconds " + RETRY_WAIT_SECONDS + "s");
|
|
||||||
}
|
|
||||||
return [2 /*return*/];
|
return [2 /*return*/];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -398,8 +396,13 @@ function runAction() {
|
|||||||
throw error_1;
|
throw error_1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (WARNING_ON_RETRY) {
|
||||||
core_1.warning("Attempt " + attempt + " failed. Reason: " + error_1.message);
|
core_1.warning("Attempt " + attempt + " failed. Reason: " + error_1.message);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
core_1.info("Attempt " + attempt + " failed. Reason: " + error_1.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
return [3 /*break*/, 6];
|
return [3 /*break*/, 6];
|
||||||
case 6:
|
case 6:
|
||||||
attempt++;
|
attempt++;
|
||||||
|
|||||||
11
src/index.ts
11
src/index.ts
@@ -13,6 +13,7 @@ const COMMAND = getInput('command', { required: true });
|
|||||||
const RETRY_WAIT_SECONDS = getInputNumber('retry_wait_seconds', false) || 10;
|
const RETRY_WAIT_SECONDS = getInputNumber('retry_wait_seconds', false) || 10;
|
||||||
const POLLING_INTERVAL_SECONDS = getInputNumber('polling_interval_seconds', false) || 1;
|
const POLLING_INTERVAL_SECONDS = getInputNumber('polling_interval_seconds', false) || 1;
|
||||||
const RETRY_ON = getInput('retry_on') || 'any';
|
const RETRY_ON = getInput('retry_on') || 'any';
|
||||||
|
const WARNING_ON_RETRY = getInput('warning_on_retry').toLowerCase() === 'true';
|
||||||
|
|
||||||
const OUTPUT_TOTAL_ATTEMPTS_KEY = 'total_attempts';
|
const OUTPUT_TOTAL_ATTEMPTS_KEY = 'total_attempts';
|
||||||
const OUTPUT_EXIT_CODE_KEY = 'exit_code';
|
const OUTPUT_EXIT_CODE_KEY = 'exit_code';
|
||||||
@@ -48,12 +49,6 @@ async function validateInputs() {
|
|||||||
if ((!TIMEOUT_MINUTES && !TIMEOUT_SECONDS) || (TIMEOUT_MINUTES && TIMEOUT_SECONDS)) {
|
if ((!TIMEOUT_MINUTES && !TIMEOUT_SECONDS) || (TIMEOUT_MINUTES && TIMEOUT_SECONDS)) {
|
||||||
throw new Error('Must specify either timeout_minutes or timeout_seconds inputs');
|
throw new Error('Must specify either timeout_minutes or timeout_seconds inputs');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TIMEOUT_SECONDS && TIMEOUT_SECONDS < RETRY_WAIT_SECONDS) {
|
|
||||||
throw new Error(
|
|
||||||
`timeout_seconds ${TIMEOUT_SECONDS}s less than retry_wait_seconds ${RETRY_WAIT_SECONDS}s`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimeout(): number {
|
function getTimeout(): number {
|
||||||
@@ -130,7 +125,11 @@ async function runAction() {
|
|||||||
// error: error
|
// error: error
|
||||||
throw error;
|
throw error;
|
||||||
} else {
|
} else {
|
||||||
|
if (WARNING_ON_RETRY) {
|
||||||
warning(`Attempt ${attempt} failed. Reason: ${error.message}`);
|
warning(`Attempt ${attempt} failed. Reason: ${error.message}`);
|
||||||
|
} else {
|
||||||
|
info(`Attempt ${attempt} failed. Reason: ${error.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user