Add configurable timeout and retry for git network operations

Add per-attempt timeout (default 300s) and Kubernetes probe-style retry
configuration for git fetch, lfs-fetch, and ls-remote. New action inputs:
timeout, retry-max-attempts, retry-min-backoff, retry-max-backoff.

Fixes https://github.com/actions/checkout/issues/631

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Anatoly Rabkin 2026-03-18 18:06:25 +02:00
parent 0c366fd6a8
commit 5df58a66d1
10 changed files with 342 additions and 81 deletions

View file

@ -161,5 +161,41 @@ export async function getInputs(): Promise<IGitSourceSettings> {
result.githubServerUrl = core.getInput('github-server-url')
core.debug(`GitHub Host URL = ${result.githubServerUrl}`)
// Timeout (per-attempt, like k8s timeoutSeconds)
result.timeout = Math.floor(Number(core.getInput('timeout') || '300'))
if (isNaN(result.timeout) || result.timeout < 0) {
result.timeout = 300
}
core.debug(`timeout = ${result.timeout}`)
// Retry max attempts (like k8s failureThreshold)
result.retryMaxAttempts = Math.floor(
Number(core.getInput('retry-max-attempts') || '3')
)
if (isNaN(result.retryMaxAttempts) || result.retryMaxAttempts < 1) {
result.retryMaxAttempts = 3
}
core.debug(`retry max attempts = ${result.retryMaxAttempts}`)
// Retry backoff (like k8s periodSeconds, but as a min/max range)
result.retryMinBackoff = Math.floor(
Number(core.getInput('retry-min-backoff') || '10')
)
if (isNaN(result.retryMinBackoff) || result.retryMinBackoff < 0) {
result.retryMinBackoff = 10
}
core.debug(`retry min backoff = ${result.retryMinBackoff}`)
result.retryMaxBackoff = Math.floor(
Number(core.getInput('retry-max-backoff') || '20')
)
if (isNaN(result.retryMaxBackoff) || result.retryMaxBackoff < 0) {
result.retryMaxBackoff = 20
}
if (result.retryMaxBackoff < result.retryMinBackoff) {
result.retryMaxBackoff = result.retryMinBackoff
}
core.debug(`retry max backoff = ${result.retryMaxBackoff}`)
return result
}