Reduce redundant CI runs, pnpm uploads, and fixture startups (#23145)

* Reduce redundant CI runs, store uploads, and fixture processes

* Avoid repeating draft-independent mobile checks on readiness

---------

Co-authored-by: m4air <m4air@m4airs-Air.localdomain>
This commit is contained in:
OrcaWin
2026-09-26 01:17:51 -07:00
committed by GitHub
co-authored by m4air
parent 2afb9a385b
commit d17a17684b
22 changed files with 1089 additions and 73 deletions
@@ -15,6 +15,7 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { getRemoteHostPlatform, type RemoteHostPlatform } from './ssh-remote-platform'
import { powerShellCommand, powerShellLiteral } from './ssh-remote-powershell'
import {
cleanupOwnedRelayUploadStageCommand,
parseReservedRelayUploadStage,
@@ -84,6 +85,22 @@ function createStage(
const reservedOwner = /^\.sftp-namespace-[0-9a-f]{32}$/u.test(stageOwner) ? stageOwner : owner
const reservation = runCommand(host, reserveRelayUploadStageCommand(host, pool, reservedOwner))
expect(reservation.status, reservation.stderr).toBe(0)
return populateReservedStage(
pool,
index,
stageOwner === reservedOwner ? undefined : stageOwner,
stale,
state
)
}
function populateReservedStage(
pool: string,
index: number,
replacementOwner?: string,
stale = false,
state: 'slot' | 'claim' | 'delete' = 'slot'
): string {
const slot = join(pool, `slot-${index}`)
const stage = join(pool, `${state}-${index}`)
if (stage !== slot) {
@@ -91,8 +108,8 @@ function createStage(
renameSync(slot, stage)
}
const marker = join(stage, '.orca-upload-owner')
if (stageOwner !== reservedOwner) {
writeFileSync(marker, stageOwner)
if (replacementOwner !== undefined) {
writeFileSync(marker, replacementOwner)
}
writeFileSync(join(stage, 'payload', 'relay.js'), `relay-${index}`)
if (stale) {
@@ -102,16 +119,48 @@ function createStage(
return stage
}
function createQuotaStages(host: RemoteHostPlatform, pool: string, count: number): void {
if (host.commandDialect !== 'powershell' || count < 2) {
for (let index = 0; index < count; index += 1) {
createStage(host, pool, index)
}
return
}
const command = reserveRelayUploadStageCommand(host, pool, owner)
// Only fixture setup shares a process; each unmodified script gets a fresh local scope.
const batch = powerShellCommand(
[
"$ErrorActionPreference = 'Stop'",
`$fixtureScript = ${powerShellLiteral(decodePowerShellCommand(command))}`,
'$reservation = [PowerShell]::Create()',
'try {',
`foreach ($fixtureIndex in 1..${count}) {`,
'$reservation.Commands.Clear()',
'$reservation.Streams.Error.Clear()',
'$null = $reservation.AddScript($fixtureScript, $true)',
'$reservation.Invoke()',
'if ($reservation.InvocationStateInfo.State -ne "Completed") { throw $reservation.InvocationStateInfo.Reason }',
'}',
'} finally { $reservation.Dispose() }'
].join('\n')
)
const result = runCommand(host, batch)
expect(result.status, result.stderr).toBe(0)
const reservations = result.stdout.trim().split(/\r?\n/u)
expect(reservations).toHaveLength(count)
for (const [index, output] of reservations.entries()) {
expect(parseReservedRelayUploadStage(host, pool, owner, output).slotName).toBe(`slot-${index}`)
populateReservedStage(pool, index)
}
}
afterEach(() => {
for (const root of roots.splice(0)) {
rmSync(root, { recursive: true, force: true })
}
})
// Why: every case spawns a real interpreter per command, and on non-Windows hosts the PowerShell
// path also forks `/usr/bin/stat` per file-identity lookup — the 8-entry reservation alone measured
// ~50s idle, nearly all of it process-spawn sys time, and the full suite multiplies that under CPU
// contention. Sized for spawn count, not the assertions, which run in microseconds.
// Allow for real interpreter startup and file-identity probes under full-suite contention.
const SPAWNED_INTERPRETER_TIMEOUT_MS = 240_000
describe.each([
@@ -126,9 +175,7 @@ describe.each([
(_label, host) => {
it.each([0, 1, 7, 8, 9])('bounds reservation with %i occupied entries', (count) => {
const pool = createPool()
for (let index = 0; index < Math.min(count, RELAY_UPLOAD_STAGE_SLOT_COUNT); index += 1) {
createStage(host, pool, index)
}
createQuotaStages(host, pool, Math.min(count, RELAY_UPLOAD_STAGE_SLOT_COUNT))
if (count > RELAY_UPLOAD_STAGE_SLOT_COUNT) {
mkdirSync(join(pool, 'foreign-extra'))
}