mirror of
https://github.com/actions/checkout.git
synced 2025-08-23 10:48:01 +03:00
Retry
This commit is contained in:
parent
ff7abcd0c3
commit
9905cd6970
8 changed files with 90 additions and 2 deletions
|
@ -125,6 +125,14 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
|
||||||
# Default: false
|
# Default: false
|
||||||
fetch-tags: ''
|
fetch-tags: ''
|
||||||
|
|
||||||
|
# Timeout in seconds for individual git/network operations (0 disables).
|
||||||
|
# Default: 0
|
||||||
|
timeout: ''
|
||||||
|
|
||||||
|
# Maximum number of retry attempts for flaky operations (min 1).
|
||||||
|
# Default: 3
|
||||||
|
retry: ''
|
||||||
|
|
||||||
# Whether to show progress status output when fetching.
|
# Whether to show progress status output when fetching.
|
||||||
# Default: true
|
# Default: true
|
||||||
show-progress: ''
|
show-progress: ''
|
||||||
|
|
|
@ -77,6 +77,12 @@ inputs:
|
||||||
fetch-tags:
|
fetch-tags:
|
||||||
description: 'Whether to fetch tags, even if fetch-depth > 0.'
|
description: 'Whether to fetch tags, even if fetch-depth > 0.'
|
||||||
default: false
|
default: false
|
||||||
|
timeout:
|
||||||
|
description: 'Timeout in seconds for individual git/network operations (0 disables).'
|
||||||
|
default: 0
|
||||||
|
retry:
|
||||||
|
description: 'Maximum number of retry attempts for flaky operations (min 1).'
|
||||||
|
default: 3
|
||||||
show-progress:
|
show-progress:
|
||||||
description: 'Whether to show progress status output when fetching.'
|
description: 'Whether to show progress status output when fetching.'
|
||||||
default: true
|
default: true
|
||||||
|
|
31
dist/index.js
vendored
31
dist/index.js
vendored
|
@ -339,6 +339,12 @@ class GitAuthHelper {
|
||||||
// Configure GIT_SSH_COMMAND
|
// Configure GIT_SSH_COMMAND
|
||||||
const sshPath = yield io.which('ssh', true);
|
const sshPath = yield io.which('ssh', true);
|
||||||
this.sshCommand = `"${sshPath}" -i "$RUNNER_TEMP/${path.basename(this.sshKeyPath)}"`;
|
this.sshCommand = `"${sshPath}" -i "$RUNNER_TEMP/${path.basename(this.sshKeyPath)}"`;
|
||||||
|
// Apply SSH ConnectTimeout if input timeout is set
|
||||||
|
const parsedTimeout = Math.floor(Number(process.env['INPUT_TIMEOUT'] || '0'));
|
||||||
|
if (!isNaN(parsedTimeout) && parsedTimeout > 0) {
|
||||||
|
// OpenSSH ConnectTimeout is in seconds
|
||||||
|
this.sshCommand += ` -o ConnectTimeout=${parsedTimeout}`;
|
||||||
|
}
|
||||||
if (this.settings.sshStrict) {
|
if (this.settings.sshStrict) {
|
||||||
this.sshCommand += ' -o StrictHostKeyChecking=yes -o CheckHostIP=no';
|
this.sshCommand += ' -o StrictHostKeyChecking=yes -o CheckHostIP=no';
|
||||||
}
|
}
|
||||||
|
@ -898,6 +904,12 @@ class GitCommandManager {
|
||||||
ignoreReturnCode: allowAllExitCodes,
|
ignoreReturnCode: allowAllExitCodes,
|
||||||
listeners: mergedListeners
|
listeners: mergedListeners
|
||||||
};
|
};
|
||||||
|
// Apply timeout from input (seconds -> ms). 0 disables.
|
||||||
|
const parsedTimeout = Math.floor(Number(process.env['INPUT_TIMEOUT'] || '0'));
|
||||||
|
if (!isNaN(parsedTimeout) && parsedTimeout > 0) {
|
||||||
|
;
|
||||||
|
options.timeout = parsedTimeout * 1000;
|
||||||
|
}
|
||||||
result.exitCode = yield exec.exec(`"${this.gitPath}"`, args, options);
|
result.exitCode = yield exec.exec(`"${this.gitPath}"`, args, options);
|
||||||
result.stdout = stdout.join('');
|
result.stdout = stdout.join('');
|
||||||
core.debug(result.exitCode.toString());
|
core.debug(result.exitCode.toString());
|
||||||
|
@ -1831,6 +1843,22 @@ function getInputs() {
|
||||||
// Determine the GitHub URL that the repository is being hosted from
|
// Determine the GitHub URL that the repository is being hosted from
|
||||||
result.githubServerUrl = core.getInput('github-server-url');
|
result.githubServerUrl = core.getInput('github-server-url');
|
||||||
core.debug(`GitHub Host URL = ${result.githubServerUrl}`);
|
core.debug(`GitHub Host URL = ${result.githubServerUrl}`);
|
||||||
|
// Retry attempts (min 1)
|
||||||
|
const retryInput = core.getInput('retry') || '3';
|
||||||
|
let retry = Math.floor(Number(retryInput));
|
||||||
|
if (isNaN(retry) || retry < 1) {
|
||||||
|
retry = 1;
|
||||||
|
}
|
||||||
|
result.retry = retry;
|
||||||
|
core.debug(`retry = ${result.retry}`);
|
||||||
|
// Timeout seconds (0 disables)
|
||||||
|
const timeoutInput = core.getInput('timeout') || '0';
|
||||||
|
let timeout = Math.floor(Number(timeoutInput));
|
||||||
|
if (isNaN(timeout) || timeout < 0) {
|
||||||
|
timeout = 0;
|
||||||
|
}
|
||||||
|
result.timeout = timeout;
|
||||||
|
core.debug(`timeout = ${result.timeout}`);
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2263,7 +2291,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.RetryHelper = void 0;
|
exports.RetryHelper = void 0;
|
||||||
exports.execute = execute;
|
exports.execute = execute;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const defaultMaxAttempts = 3;
|
const parsedRetry = Math.floor(Number(process.env['INPUT_RETRY'] || ''));
|
||||||
|
const defaultMaxAttempts = !isNaN(parsedRetry) && parsedRetry > 0 ? parsedRetry : 3;
|
||||||
const defaultMinSeconds = 10;
|
const defaultMinSeconds = 10;
|
||||||
const defaultMaxSeconds = 20;
|
const defaultMaxSeconds = 20;
|
||||||
class RetryHelper {
|
class RetryHelper {
|
||||||
|
|
|
@ -257,6 +257,14 @@ class GitAuthHelper {
|
||||||
this.sshCommand = `"${sshPath}" -i "$RUNNER_TEMP/${path.basename(
|
this.sshCommand = `"${sshPath}" -i "$RUNNER_TEMP/${path.basename(
|
||||||
this.sshKeyPath
|
this.sshKeyPath
|
||||||
)}"`
|
)}"`
|
||||||
|
// Apply SSH ConnectTimeout if input timeout is set
|
||||||
|
const parsedTimeout = Math.floor(
|
||||||
|
Number(process.env['INPUT_TIMEOUT'] || '0')
|
||||||
|
)
|
||||||
|
if (!isNaN(parsedTimeout) && parsedTimeout > 0) {
|
||||||
|
// OpenSSH ConnectTimeout is in seconds
|
||||||
|
this.sshCommand += ` -o ConnectTimeout=${parsedTimeout}`
|
||||||
|
}
|
||||||
if (this.settings.sshStrict) {
|
if (this.settings.sshStrict) {
|
||||||
this.sshCommand += ' -o StrictHostKeyChecking=yes -o CheckHostIP=no'
|
this.sshCommand += ' -o StrictHostKeyChecking=yes -o CheckHostIP=no'
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,6 +539,14 @@ class GitCommandManager {
|
||||||
listeners: mergedListeners
|
listeners: mergedListeners
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply timeout from input (seconds -> ms). 0 disables.
|
||||||
|
const parsedTimeout = Math.floor(
|
||||||
|
Number(process.env['INPUT_TIMEOUT'] || '0')
|
||||||
|
)
|
||||||
|
if (!isNaN(parsedTimeout) && parsedTimeout > 0) {
|
||||||
|
;(options as any).timeout = parsedTimeout * 1000
|
||||||
|
}
|
||||||
|
|
||||||
result.exitCode = await exec.exec(`"${this.gitPath}"`, args, options)
|
result.exitCode = await exec.exec(`"${this.gitPath}"`, args, options)
|
||||||
result.stdout = stdout.join('')
|
result.stdout = stdout.join('')
|
||||||
|
|
||||||
|
|
|
@ -118,4 +118,14 @@ export interface IGitSourceSettings {
|
||||||
* User override on the GitHub Server/Host URL that hosts the repository to be cloned
|
* User override on the GitHub Server/Host URL that hosts the repository to be cloned
|
||||||
*/
|
*/
|
||||||
githubServerUrl: string | undefined
|
githubServerUrl: string | undefined
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout in seconds for individual git/network operations (0 disables)
|
||||||
|
*/
|
||||||
|
timeout?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of retry attempts for flaky operations (min 1)
|
||||||
|
*/
|
||||||
|
retry?: number
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,5 +161,23 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
||||||
result.githubServerUrl = core.getInput('github-server-url')
|
result.githubServerUrl = core.getInput('github-server-url')
|
||||||
core.debug(`GitHub Host URL = ${result.githubServerUrl}`)
|
core.debug(`GitHub Host URL = ${result.githubServerUrl}`)
|
||||||
|
|
||||||
|
// Retry attempts (min 1)
|
||||||
|
const retryInput = core.getInput('retry') || '3'
|
||||||
|
let retry = Math.floor(Number(retryInput))
|
||||||
|
if (isNaN(retry) || retry < 1) {
|
||||||
|
retry = 1
|
||||||
|
}
|
||||||
|
result.retry = retry
|
||||||
|
core.debug(`retry = ${result.retry}`)
|
||||||
|
|
||||||
|
// Timeout seconds (0 disables)
|
||||||
|
const timeoutInput = core.getInput('timeout') || '0'
|
||||||
|
let timeout = Math.floor(Number(timeoutInput))
|
||||||
|
if (isNaN(timeout) || timeout < 0) {
|
||||||
|
timeout = 0
|
||||||
|
}
|
||||||
|
result.timeout = timeout
|
||||||
|
core.debug(`timeout = ${result.timeout}`)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
|
||||||
const defaultMaxAttempts = 3
|
const parsedRetry = Math.floor(Number(process.env['INPUT_RETRY'] || ''))
|
||||||
|
const defaultMaxAttempts = !isNaN(parsedRetry) && parsedRetry > 0 ? parsedRetry : 3
|
||||||
const defaultMinSeconds = 10
|
const defaultMinSeconds = 10
|
||||||
const defaultMaxSeconds = 20
|
const defaultMaxSeconds = 20
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue