mirror of https://github.com/actions/checkout
Compare commits
2 Commits
047af58489
...
43ff85c385
| Author | SHA1 | Date |
|---|---|---|
|
|
43ff85c385 | |
|
|
33c1ac53d1 |
|
|
@ -516,29 +516,19 @@ describe('timeout and retry configuration', () => {
|
|||
jest.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('setTimeout accepts valid values', async () => {
|
||||
it('setTimeout converts seconds to milliseconds', async () => {
|
||||
git = await createMockGit()
|
||||
// Should not throw
|
||||
git.setTimeout(30)
|
||||
git.setTimeout(0)
|
||||
})
|
||||
|
||||
it('setTimeout rejects negative values', async () => {
|
||||
git = await createMockGit()
|
||||
expect(() => git.setTimeout(-1)).toThrow(/non-negative/)
|
||||
})
|
||||
|
||||
it('setRetryConfig accepts valid parameters', async () => {
|
||||
git = await createMockGit()
|
||||
// Should not throw
|
||||
git.setRetryConfig(5, 2, 15)
|
||||
})
|
||||
|
||||
it('setRetryConfig rejects min > max backoff', async () => {
|
||||
git = await createMockGit()
|
||||
expect(() => git.setRetryConfig(3, 20, 5)).toThrow(
|
||||
/min seconds should be less than or equal to max seconds/
|
||||
)
|
||||
})
|
||||
|
||||
it('fetch without timeout uses exec', async () => {
|
||||
git = await createMockGit()
|
||||
// timeout defaults to 0 (disabled)
|
||||
|
|
@ -550,28 +540,6 @@ describe('timeout and retry configuration', () => {
|
|||
const fetchCalls = mockExec.mock.calls.filter(
|
||||
(call: any[]) => (call[1] as string[]).includes('fetch')
|
||||
)
|
||||
expect(fetchCalls).toHaveLength(1)
|
||||
expect(fetchCalls.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it('fetch with timeout does not use exec', async () => {
|
||||
git = await createMockGit()
|
||||
// Short timeout and single attempt so the test completes quickly
|
||||
git.setTimeout(1)
|
||||
git.setRetryConfig(1, 0, 0)
|
||||
|
||||
mockExec.mockClear()
|
||||
|
||||
// fetch will use spawn path (which will fail/timeout since there's
|
||||
// no real git repo), but we verify exec.exec was NOT called for fetch
|
||||
try {
|
||||
await git.fetch(['refs/heads/main'], {})
|
||||
} catch {
|
||||
// Expected: spawn will fail/timeout in test environment
|
||||
}
|
||||
|
||||
const fetchCalls = mockExec.mock.calls.filter(
|
||||
(call: any[]) => (call[1] as string[]).includes('fetch')
|
||||
)
|
||||
expect(fetchCalls).toHaveLength(0)
|
||||
}, 10000)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -171,14 +171,11 @@ describe('input-helper tests', () => {
|
|||
expect(settings.retryMaxBackoff).toBe(15)
|
||||
})
|
||||
|
||||
it('clamps retry-max-backoff to min when less than min and warns', async () => {
|
||||
it('clamps retry-max-backoff to min when less than min', async () => {
|
||||
inputs['retry-min-backoff'] = '20'
|
||||
inputs['retry-max-backoff'] = '5'
|
||||
const settings: IGitSourceSettings = await inputHelper.getInputs()
|
||||
expect(settings.retryMaxBackoff).toBe(20)
|
||||
expect(core.warning).toHaveBeenCalledWith(
|
||||
expect.stringContaining("'retry-max-backoff' (5) is less than 'retry-min-backoff' (20)")
|
||||
)
|
||||
})
|
||||
|
||||
it('defaults invalid timeout to 300 and warns', async () => {
|
||||
|
|
|
|||
|
|
@ -980,10 +980,7 @@ class GitCommandManager {
|
|||
if (recursive) {
|
||||
args.push('--recursive');
|
||||
}
|
||||
const that = this;
|
||||
yield this.networkRetryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
||||
yield that.execGit(args, { timeoutMs: that.timeoutMs });
|
||||
}));
|
||||
yield this.execGit(args);
|
||||
});
|
||||
}
|
||||
submoduleUpdate(fetchDepth, recursive) {
|
||||
|
|
@ -996,10 +993,7 @@ class GitCommandManager {
|
|||
if (recursive) {
|
||||
args.push('--recursive');
|
||||
}
|
||||
const that = this;
|
||||
yield this.networkRetryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
||||
yield that.execGit(args, { timeoutMs: that.timeoutMs });
|
||||
}));
|
||||
yield this.execGit(args);
|
||||
});
|
||||
}
|
||||
submoduleStatus() {
|
||||
|
|
@ -1247,16 +1241,13 @@ class GitCommandManager {
|
|||
forceKillTimer.unref();
|
||||
}
|
||||
}, timeoutMs);
|
||||
if (timer.unref) {
|
||||
timer.unref();
|
||||
}
|
||||
child.on('close', (code) => {
|
||||
if (settled)
|
||||
return;
|
||||
settled = true;
|
||||
cleanup();
|
||||
if (timedOut) {
|
||||
reject(new Error(`Git operation timed out after ${timeoutMs / 1000} seconds: git ${args.slice(0, 5).join(' ')}...`));
|
||||
reject(new Error(`Git operation timed out after ${timeoutMs / 1000} seconds: git ${args.slice(0, 3).join(' ')}...`));
|
||||
return;
|
||||
}
|
||||
// null code means killed by signal (e.g. OOM killer, external SIGTERM)
|
||||
|
|
@ -2272,7 +2263,6 @@ function getInputs() {
|
|||
result.retryMaxBackoff = 20;
|
||||
}
|
||||
if (result.retryMaxBackoff < result.retryMinBackoff) {
|
||||
core.warning(`'retry-max-backoff' (${result.retryMaxBackoff}) is less than 'retry-min-backoff' (${result.retryMinBackoff}). Using retry-min-backoff value for both.`);
|
||||
result.retryMaxBackoff = result.retryMinBackoff;
|
||||
}
|
||||
core.debug(`retry max backoff = ${result.retryMaxBackoff}`);
|
||||
|
|
|
|||
|
|
@ -455,10 +455,7 @@ class GitCommandManager {
|
|||
args.push('--recursive')
|
||||
}
|
||||
|
||||
const that = this
|
||||
await this.networkRetryHelper.execute(async () => {
|
||||
await that.execGit(args, {timeoutMs: that.timeoutMs})
|
||||
})
|
||||
await this.execGit(args)
|
||||
}
|
||||
|
||||
async submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void> {
|
||||
|
|
@ -472,10 +469,7 @@ class GitCommandManager {
|
|||
args.push('--recursive')
|
||||
}
|
||||
|
||||
const that = this
|
||||
await this.networkRetryHelper.execute(async () => {
|
||||
await that.execGit(args, {timeoutMs: that.timeoutMs})
|
||||
})
|
||||
await this.execGit(args)
|
||||
}
|
||||
|
||||
async submoduleStatus(): Promise<boolean> {
|
||||
|
|
@ -805,9 +799,6 @@ class GitCommandManager {
|
|||
forceKillTimer.unref()
|
||||
}
|
||||
}, timeoutMs)
|
||||
if (timer.unref) {
|
||||
timer.unref()
|
||||
}
|
||||
|
||||
child.on('close', (code: number | null) => {
|
||||
if (settled) return
|
||||
|
|
@ -817,7 +808,7 @@ class GitCommandManager {
|
|||
if (timedOut) {
|
||||
reject(
|
||||
new Error(
|
||||
`Git operation timed out after ${timeoutMs / 1000} seconds: git ${args.slice(0, 5).join(' ')}...`
|
||||
`Git operation timed out after ${timeoutMs / 1000} seconds: git ${args.slice(0, 3).join(' ')}...`
|
||||
)
|
||||
)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -209,9 +209,6 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||
result.retryMaxBackoff = 20
|
||||
}
|
||||
if (result.retryMaxBackoff < result.retryMinBackoff) {
|
||||
core.warning(
|
||||
`'retry-max-backoff' (${result.retryMaxBackoff}) is less than 'retry-min-backoff' (${result.retryMinBackoff}). Using retry-min-backoff value for both.`
|
||||
)
|
||||
result.retryMaxBackoff = result.retryMinBackoff
|
||||
}
|
||||
core.debug(`retry max backoff = ${result.retryMaxBackoff}`)
|
||||
|
|
|
|||
Loading…
Reference in New Issue