Files
orca/tests/e2e/cross-version-wire/release-checkout-prefetch.ts
Brennan Benson c46e84bcc4 test: fix historical compatibility setup reliability (#37905)
Prepare requested immutable historical snapshots before timed extraction and direct reads, using the existing acquisition/process helpers and local-only consumers. Move four suites' historical module setup into per-pin hooks without changing pins, compatibility assertions, workers, extraction/assertion deadlines or publication ownership.

Independent reviews and the binding design settlement passed. The cold comparison and normal uninstrumented final-head CI each passed49files197tests; normal Checkout62s/job276s. All temporary probes removed; brennan-ready READY.

Tracked in STA-13683. Outer-hook failure attribution limitation tracked in STA-13703. No application, saved-data or wire behavior change.
2026-11-03 15:39:06 -08:00

66 lines
1.9 KiB
TypeScript

import { runCheckoutProcess } from './release-checkout-process.ts'
const PREPARATION_TIMEOUT_MS = 60_000
export async function prepareReleaseSnapshotSource(
repoRoot: string,
commit: string,
{ timeoutMs = PREPARATION_TIMEOUT_MS } = {}
): Promise<void> {
const deadline = Date.now() + timeoutMs
const git = (args: string[], input?: string): Promise<string> =>
runCheckoutProcess(repoRoot, 'git', args, deadline, {
input,
maxOutputBytes: 16 * 1024 * 1024,
timeoutMs
})
// Starting at the tree visits this snapshot, not the commit's ancestry.
const missingObjects = async (): Promise<string[]> =>
(
await git([
'rev-list',
'--objects',
'--no-object-names',
'--missing=print',
`${commit}^{tree}`
])
)
.split('\n')
.filter((line) => line.startsWith('?'))
.map((line) => line.slice(1))
try {
const missing = await missingObjects()
if (missing.length !== 0) {
const remotes = await git(['config', '--get-regexp', '^remote[.].*[.]promisor$'])
const remote = /^remote\.(.+)\.promisor (?:true|1)$/m.exec(remotes)?.[1]
if (!remote) {
throw new Error('Missing snapshot objects without a promisor remote')
}
await git(
[
'-c',
'fetch.negotiationAlgorithm=noop',
'-c',
'maintenance.auto=false',
'-c',
'gc.auto=0',
'fetch',
'--quiet',
'--no-tags',
'--no-write-fetch-head',
'--recurse-submodules=no',
'--filter=blob:none',
remote,
'--stdin'
],
`${missing.join('\n')}\n`
)
if ((await missingObjects()).length !== 0) {
throw new Error('Requested snapshot objects remain unavailable')
}
}
} catch (error) {
throw new Error(`Historical source preparation: ${String(error)}`)
}
}