Files
orca/config/scripts/pr-ready-check-gate.test.mjs
T
Neil 1912c90141 Extract subprocess handling into @orca/process-host (#26963)
Extract subprocess execution and process contracts into @orca/process-host with explicit public entry points, independent checks, and one Node 18 compatible CommonJS runtime. Migrate application consumers and integrate package builds, dependency selection, import enforcement, and runtime resource staging.

Preserve daemon startup ownership and profile isolation, and qualify development rebuild recovery and concurrent output publication. Remove unnecessary aliases, test forwarding exports, and a duplicate output scan.

Validation: full typechecks, changed-code quality, package and artifact checks, native Windows builds/types plus 306 runtime tests, and independent native reviews.

Matched full E2E controls on original main and unchanged reviewed head both pass all 17 applicable tests (nine skips). Earlier intermittent E2E failures are documented in the PR; no assertions were weakened. The final combined-tree audit preserves both branches with no import-boundary violations.
2026-10-09 18:32:28 -07:00

71 lines
2.5 KiB
JavaScript

import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
import { parse } from 'yaml'
import { runProcess } from '@orca/process-host'
import { PR_CHECK_JOBS } from './pr-code-change-scope.mjs'
const workflow = parse(readFileSync('.github/workflows/pr.yml', 'utf8'))
const gate = workflow.jobs.verify.steps.find((step) => step.name === 'Require successful checks')
const variable = (job) => job.replaceAll('-', '_').toUpperCase()
const requiredJobs = [
'preflight',
...PR_CHECK_JOBS.filter((job) => job !== 'static_analysis' && job !== 'typecheck')
]
function requiredResults(shouldRun) {
return Object.fromEntries(
requiredJobs.flatMap((job) => [
[variable(job), shouldRun ? 'success' : 'skipped'],
[`${variable(job)}_SHOULD_RUN`, String(shouldRun)]
])
)
}
async function verify(results) {
return runProcess({
program: 'bash',
args: ['-c', gate.run],
env: {
...process.env,
ORCA_BACKGROUND_LAUNCH: '1',
CODE_PATHS: 'success',
SHOULD_RUN: 'true',
...results
},
timeoutMs: 10_000
})
}
// The aggregate runs as Bash on Linux; Windows has no required Bash installation.
describe.skipIf(process.platform === 'win32')(
'readiness reuse through the real aggregate gate',
() => {
it('accepts completed required checks or skips authorized by exact-source evidence', async () => {
expect((await verify(requiredResults(true))).code).toBe(0)
expect((await verify(requiredResults(false))).code).toBe(0)
})
it('rejects every missing, failed or cancelled required result when reuse is unavailable', async () => {
for (const job of requiredJobs) {
for (const result of ['', 'skipped', 'failure', 'cancelled']) {
const verdict = await verify({ ...requiredResults(true), [variable(job)]: result })
expect(verdict.code, `${job}: ${result}`).toBe(1)
}
}
})
it('requires the detector to succeed even when every downstream job is skipped', async () => {
for (const result of ['', 'skipped', 'failure', 'cancelled']) {
expect((await verify({ ...requiredResults(false), CODE_PATHS: result })).code).toBe(1)
}
})
it('rejects unexpected downstream execution when the proven plan requires skips', async () => {
for (const job of requiredJobs) {
const verdict = await verify({ ...requiredResults(false), [variable(job)]: 'success' })
expect(verdict.code, job).toBe(1)
}
})
}
)