run-gates.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /**
  2. * Run local and CI quality gates with bounded in-process scheduling.
  3. *
  4. * The gate vocabulary stays in package.json; this runner only decides which
  5. * independent commands can overlap and which commands wait for built artifacts.
  6. */
  7. import { spawn } from 'node:child_process'
  8. import { readdir, rm } from 'node:fs/promises'
  9. import { availableParallelism } from 'node:os'
  10. import { join, resolve } from 'node:path'
  11. import { performance } from 'node:perf_hooks'
  12. type Mode =
  13. | 'ci-primary'
  14. | 'ci-static'
  15. | 'ci-lint'
  16. | 'ci-coverage'
  17. | 'ci-snapshot'
  18. | 'ci-artifacts'
  19. | 'node-compat'
  20. | 'pre-push'
  21. type GateStatus = 'pending' | 'running' | 'passed' | 'failed' | 'skipped'
  22. interface Gate {
  23. id: string
  24. label: string
  25. displayCommand: string
  26. command: string
  27. args: string[]
  28. needs?: string[]
  29. env?: Record<string, string | undefined>
  30. input?: string
  31. verify?: (result: GateResult) => Promise<void>
  32. }
  33. interface GateResult {
  34. gate: Gate
  35. status: GateStatus
  36. durationMs: number
  37. stdout: string
  38. stderr: string
  39. output: GateOutputChunk[]
  40. exitCode: number | null
  41. error?: string
  42. }
  43. interface GateOutputChunk {
  44. stream: 'stdout' | 'stderr'
  45. text: string
  46. }
  47. interface RunningGate {
  48. gate: Gate
  49. promise: Promise<GateResult>
  50. }
  51. interface ConcurrencyDefault {
  52. workers: number
  53. source: string
  54. }
  55. const root = resolve(import.meta.dirname, '..')
  56. const mode = parseMode(process.argv[2])
  57. const gates = gatesForMode(mode)
  58. const concurrencyDefault = defaultConcurrency(mode, gates.length)
  59. const concurrencyOverride = process.env.DSH_GATE_CONCURRENCY
  60. const maxConcurrency = concurrencyFromEnv('DSH_GATE_CONCURRENCY', concurrencyDefault.workers)
  61. const verbose = process.env.DSH_GATE_VERBOSE === '1'
  62. const startedAt = performance.now()
  63. const concurrencySource = concurrencyOverride === undefined || concurrencyOverride === ''
  64. ? concurrencyDefault.source
  65. : '$DSH_GATE_CONCURRENCY'
  66. console.log(`run-gates: ${mode} running ${gates.length} gate(s) with ${maxConcurrency} worker(s) from ${concurrencySource}.`)
  67. const results = await runGates(gates, maxConcurrency)
  68. printSummary(results, performance.now() - startedAt)
  69. if (results.some(result => result.status === 'failed' || result.status === 'skipped')) process.exit(1)
  70. function parseMode(raw: string | undefined): Mode {
  71. switch (raw) {
  72. case 'ci-primary':
  73. case 'ci-static':
  74. case 'ci-lint':
  75. case 'ci-coverage':
  76. case 'ci-snapshot':
  77. case 'ci-artifacts':
  78. case 'node-compat':
  79. case 'pre-push':
  80. return raw
  81. default:
  82. throw new Error(
  83. `run-gates: expected mode ci-primary | ci-static | ci-lint | ci-coverage | ci-snapshot | ci-artifacts | node-compat | pre-push, got ${JSON.stringify(raw)}.`,
  84. )
  85. }
  86. }
  87. function defaultConcurrency(selectedMode: Mode, total: number): ConcurrencyDefault {
  88. const available = availableParallelism()
  89. const modeLimit = selectedMode === 'pre-push' ? Math.min(4, available) : available
  90. return {
  91. workers: Math.min(total, modeLimit),
  92. source: selectedMode === 'pre-push'
  93. ? `${available} available CPU(s), pre-push cap 4`
  94. : `${available} available CPU(s)`,
  95. }
  96. }
  97. function concurrencyFromEnv(name: string, fallback: number): number {
  98. const raw = process.env[name]
  99. if (raw === undefined || raw === '') return fallback
  100. const parsed = Number.parseInt(raw, 10)
  101. if (!Number.isSafeInteger(parsed) || parsed < 1) {
  102. throw new Error(`run-gates: ${name} must be a positive integer, got ${JSON.stringify(raw)}.`)
  103. }
  104. return parsed
  105. }
  106. function pnpmScript(id: string, script: string, options: Partial<Gate> = {}): Gate {
  107. return {
  108. id,
  109. label: options.label ?? script,
  110. displayCommand: `pnpm run ${script}`,
  111. ...pnpmInvocation(['run', script]),
  112. ...options,
  113. }
  114. }
  115. function pnpmExec(id: string, args: string[], options: Partial<Gate> = {}): Gate {
  116. return {
  117. id,
  118. label: options.label ?? `pnpm exec ${args.join(' ')}`,
  119. displayCommand: `pnpm exec ${args.join(' ')}`,
  120. ...pnpmInvocation(['exec', ...args]),
  121. ...options,
  122. }
  123. }
  124. function pnpmInvocation(args: string[]): Pick<Gate, 'command' | 'args'> {
  125. const entrypoint = process.env.npm_execpath
  126. if (entrypoint === undefined || entrypoint === '') {
  127. throw new Error('run-gates: npm_execpath is unavailable; invoke the runner through a pnpm package script.')
  128. }
  129. // Windows cannot spawn the pnpm.cmd shim directly; the JavaScript entrypoint keeps every host shell-free.
  130. return { command: process.execPath, args: [entrypoint, ...args] }
  131. }
  132. function nodeOptions(...options: string[]): string {
  133. return [process.env.NODE_OPTIONS, ...options].filter(option => option !== undefined && option !== '').join(' ')
  134. }
  135. function gatesForMode(selected: Mode): Gate[] {
  136. switch (selected) {
  137. case 'ci-primary':
  138. return ciPrimaryGates()
  139. case 'ci-static':
  140. return ciStaticGates()
  141. case 'ci-lint':
  142. return [
  143. lintGate(),
  144. pnpmScript('duplication', 'duplication'),
  145. ]
  146. case 'ci-coverage':
  147. return [
  148. pnpmScript('build', 'build'),
  149. coverageGate(),
  150. ]
  151. case 'ci-snapshot':
  152. return [
  153. pnpmScript('build', 'build'),
  154. snapshotGate(),
  155. ]
  156. case 'ci-artifacts':
  157. return ciArtifactGates()
  158. case 'node-compat':
  159. return [
  160. pnpmScript('typecheck', 'typecheck'),
  161. pnpmExec('source-worker-smoke', [
  162. 'vitest',
  163. 'run',
  164. 'packages/workflow/workflow-workerthread/tests/source-worker.compat.spec.ts',
  165. ], { label: 'source worker smoke' }),
  166. ]
  167. case 'pre-push':
  168. return [
  169. pnpmScript('runtime-closure', 'verify-runtime-closure', { label: 'runtime closure' }),
  170. pnpmScript('cordis-config', 'verify-cordis-config', { label: 'Cordis config' }),
  171. pnpmScript('test', 'test'),
  172. pnpmScript('duplication', 'duplication'),
  173. snapshotGate(),
  174. pnpmScript('build', 'build'),
  175. ...hygieneLeafGates({ artifactNeeds: ['build'] }),
  176. ...docSyncLeafGates({
  177. docTypecheckNeeds: ['build'],
  178. docTypecheckEnv: { DSH_DOC_TYPECHECK_USE_BUILD_OUTPUT: '1' },
  179. }),
  180. pnpmScript('module-graph', 'verify-module-graph', { label: 'module graph' }),
  181. ]
  182. }
  183. }
  184. function ciPrimaryGates(): Gate[] {
  185. return [
  186. pnpmScript('runtime-closure', 'verify-runtime-closure', { label: 'runtime closure' }),
  187. pnpmScript('constraints', 'constraints'),
  188. pnpmScript('cordis-config', 'verify-cordis-config', { label: 'Cordis config' }),
  189. pnpmScript('typecheck', 'typecheck'),
  190. lintGate(),
  191. pnpmScript('duplication', 'duplication'),
  192. coverageGate(),
  193. snapshotGate(),
  194. demoSmokeGate({ needs: ['lint'] }),
  195. ...docSyncLeafGates(),
  196. pnpmScript('module-graph', 'verify-module-graph', { label: 'module graph' }),
  197. pnpmScript('knip', 'knip'),
  198. pnpmScript('build', 'build', { needs: ['typecheck'] }),
  199. pnpmScript('publint', 'publint', { needs: ['build'] }),
  200. pnpmScript('node-next-types', 'verify-node-next-types', {
  201. label: 'node-next types',
  202. needs: ['build'],
  203. }),
  204. builtBinSmokeGate(),
  205. ]
  206. }
  207. function ciStaticGates(): Gate[] {
  208. return [
  209. pnpmScript('runtime-closure', 'verify-runtime-closure', { label: 'runtime closure' }),
  210. pnpmScript('constraints', 'constraints'),
  211. pnpmScript('cordis-config', 'verify-cordis-config', { label: 'Cordis config' }),
  212. ...staticDemoSmokeGates(),
  213. ...docSyncLeafGates(),
  214. pnpmScript('module-graph', 'verify-module-graph', { label: 'module graph' }),
  215. pnpmScript('knip', 'knip'),
  216. ]
  217. }
  218. function staticDemoSmokeGates(): Gate[] {
  219. // Native Windows session persistence is outside the gates-only support scope.
  220. return process.platform === 'win32' ? [] : [demoSmokeGate()]
  221. }
  222. function ciArtifactGates(): Gate[] {
  223. return [
  224. pnpmScript('build', 'build'),
  225. pnpmScript('publint', 'publint', { needs: ['build'] }),
  226. pnpmScript('node-next-types', 'verify-node-next-types', {
  227. label: 'node-next types',
  228. needs: ['build'],
  229. }),
  230. builtBinSmokeGate(),
  231. ]
  232. }
  233. function lintGate(): Gate {
  234. if (process.env.DSH_ESLINT_CACHE === '1') {
  235. return pnpmExec('lint', [
  236. 'eslint',
  237. '.',
  238. '--cache',
  239. '--cache-location',
  240. '.cache/eslint/',
  241. '--cache-strategy',
  242. 'content',
  243. ], {
  244. label: 'lint',
  245. env: { NODE_OPTIONS: nodeOptions('--max-old-space-size=8192') },
  246. })
  247. }
  248. return pnpmScript('lint', 'lint', {
  249. env: { NODE_OPTIONS: nodeOptions('--max-old-space-size=8192') },
  250. })
  251. }
  252. function coverageGate(): Gate {
  253. return pnpmExec('coverage', [
  254. 'vitest',
  255. 'run',
  256. '--coverage',
  257. ...positiveIntArg('DSH_COVERAGE_MAX_WORKERS', '--maxWorkers'),
  258. ], {
  259. label: 'test:coverage',
  260. env: { DSH_EXAMPLE_MODE: 'lib' },
  261. needs: ['build'],
  262. })
  263. }
  264. // The snapshot suite boots the example bins in `lib` mode (built artifact under plain Node,
  265. // plugins via real exports) — CI and pre-push already build, so they exercise what ships rather
  266. // than the tsx/source path dev uses. It therefore waits on `build`.
  267. function snapshotGate(): Gate {
  268. return pnpmScript('snapshot', 'test:snapshot', {
  269. env: { DSH_EXAMPLE_MODE: 'lib' },
  270. needs: ['build'],
  271. })
  272. }
  273. function positiveIntArg(envName: string, flag: string): string[] {
  274. const raw = process.env[envName]
  275. if (raw === undefined || raw === '') return []
  276. const parsed = Number.parseInt(raw, 10)
  277. if (!Number.isSafeInteger(parsed) || parsed < 1 || String(parsed) !== raw) {
  278. throw new Error(`run-gates: ${envName} must be a positive integer, got ${JSON.stringify(raw)}.`)
  279. }
  280. return [`${flag}=${raw}`]
  281. }
  282. function hygieneLeafGates(options: { artifactNeeds?: string[] } = {}): Gate[] {
  283. const artifactOptions = options.artifactNeeds === undefined ? {} : { needs: options.artifactNeeds }
  284. return [
  285. pnpmScript('knip', 'knip'),
  286. pnpmScript('publint', 'publint', artifactOptions),
  287. pnpmScript('constraints', 'constraints'),
  288. pnpmScript('node-next-types', 'verify-node-next-types', {
  289. label: 'node-next types',
  290. ...artifactOptions,
  291. }),
  292. ]
  293. }
  294. function docSyncLeafGates(options: {
  295. docTypecheckNeeds?: string[]
  296. docTypecheckEnv?: Record<string, string | undefined>
  297. } = {}): Gate[] {
  298. const docTypecheckOptions: Partial<Gate> = {}
  299. if (options.docTypecheckNeeds !== undefined) docTypecheckOptions.needs = options.docTypecheckNeeds
  300. if (options.docTypecheckEnv !== undefined) docTypecheckOptions.env = options.docTypecheckEnv
  301. return [
  302. pnpmScript('doc-typecheck', 'doc-typecheck', docTypecheckOptions),
  303. pnpmScript('cordis-catalog', 'verify-cordis-catalog', { label: 'cordis catalog' }),
  304. pnpmScript('export-jsdoc', 'verify-export-jsdoc', { label: 'export jsdoc' }),
  305. pnpmScript('tool-catalog', 'verify-tool-catalog', { label: 'tool catalog' }),
  306. pnpmScript('config-catalog', 'verify-config-catalog', { label: 'config catalog' }),
  307. pnpmScript('persistence-catalog', 'verify-persistence-catalog', { label: 'persistence catalog' }),
  308. pnpmScript('doc-graphs', 'verify-doc-graphs', { label: 'doc graphs' }),
  309. pnpmScript('scoped-events', 'verify-scoped-events', { label: 'scoped events' }),
  310. pnpmScript('markdown-wrap', 'verify-md-wrap', { label: 'markdown wrap' }),
  311. pnpmScript('markdown-links', 'verify-md-links', { label: 'markdown links' }),
  312. pnpmScript('doc-refs', 'verify-doc-refs', { label: 'doc refs' }),
  313. pnpmScript('package-paths', 'verify-package-paths', { label: 'package paths' }),
  314. pnpmScript('package-readme-model-experience', 'verify-package-readme-model-experience', { label: 'package README model experience' }),
  315. pnpmScript('mermaid', 'verify-mermaid'),
  316. pnpmScript('agent-note-classification', 'verify-agent-note-classification', { label: 'agent note classification' }),
  317. pnpmScript('agent-note-format', 'verify-agent-note-format', { label: 'agent note format' }),
  318. pnpmScript('type-equivalence', 'verify-type-equiv', { label: 'type equivalence' }),
  319. pnpmScript('translation-prompt', 'verify-translation-prompt', { label: 'translation prompt' }),
  320. pnpmScript('translation-pairing', 'verify-translation-pairing', { label: 'translation pairing' }),
  321. pnpmScript('doc-budgets', 'verify-doc-budgets', { label: 'doc budgets' }),
  322. // Keep the VitePress build in this single gate because projection rewrites website/.generated.
  323. pnpmScript('docs-site', 'docs:check', { label: 'documentation site' }),
  324. pnpmScript('package-readme-limitations', 'verify-package-readme-limitations', { label: 'package README limitations' }),
  325. ]
  326. }
  327. function demoSmokeGate(options: { needs?: string[] } = {}): Gate {
  328. const dependencyOptions = options.needs === undefined ? {} : { needs: options.needs }
  329. return {
  330. id: 'demo-smoke',
  331. label: 'demo smoke',
  332. displayCommand: 'pnpm run demo:echo',
  333. ...pnpmInvocation(['run', 'demo:echo']),
  334. input: 'echo ci smoke\n',
  335. ...dependencyOptions,
  336. verify: async (result) => {
  337. const output = result.stdout + result.stderr
  338. const sessionsRoot = join(root, '.sessions')
  339. try {
  340. if (!output.includes('[tool call] echo({"text":"ci smoke"})')) {
  341. throw new Error('demo smoke did not show the echo tool call.')
  342. }
  343. if (!output.includes('[tool result] ECHO: CI SMOKE')) {
  344. throw new Error('demo smoke did not show the echo tool result.')
  345. }
  346. const buckets = await readdir(sessionsRoot, { withFileTypes: true })
  347. let found = false
  348. for (const bucket of buckets) {
  349. if (!bucket.isDirectory() || !bucket.name.startsWith('cwd-')) continue
  350. const entries = await readdir(join(sessionsRoot, bucket.name))
  351. if (entries.some(entry => /^main-session-.+\.jsonl$/.test(entry))) {
  352. found = true
  353. break
  354. }
  355. }
  356. if (!found) throw new Error('demo smoke did not create a main-session JSONL log in a cwd bucket.')
  357. } finally {
  358. await rm(sessionsRoot, { recursive: true, force: true })
  359. }
  360. },
  361. }
  362. }
  363. function builtBinSmokeGate(): Gate {
  364. return pnpmExec('built-bin-smoke', [
  365. 'vitest',
  366. 'run',
  367. '--config',
  368. 'vitest.e2e.config.ts',
  369. 'packages/examples/stdio-demo/tests/built-bin.e2e.ts',
  370. 'packages/examples/cli-demo/tests/built-bin.e2e.ts',
  371. 'packages/examples/acp-demo/tests/built-bin.e2e.ts',
  372. 'packages/ui/jsonrpc/tests/built-scope-carrier.e2e.ts',
  373. // The worker-entry packages' built bundles: the only automated proof
  374. // that lib/index.js resolves its sibling lib/worker.cjs under plain node
  375. // (the e2e lane runs unbuilt, so these files self-skip there).
  376. 'packages/workflow/workflow-workerthread/tests/built-worker.e2e.ts',
  377. 'packages/code-runtime/code-runtime-worker/tests/built-lib.e2e.ts',
  378. ], {
  379. label: 'built-bin smoke',
  380. needs: ['build'],
  381. })
  382. }
  383. async function runGates(allGates: Gate[], maxActive: number): Promise<GateResult[]> {
  384. const states = new Map<string, GateStatus>(allGates.map(gate => [gate.id, 'pending']))
  385. const results = new Map<string, GateResult>()
  386. const running: RunningGate[] = []
  387. for (;;) {
  388. let madeProgress = false
  389. while (running.length < maxActive) {
  390. const ready = allGates.find(gate => states.get(gate.id) === 'pending' && dependenciesPassed(gate, states))
  391. if (ready === undefined) break
  392. states.set(ready.id, 'running')
  393. running.push({ gate: ready, promise: runGate(ready) })
  394. console.log(`run-gates: start ${ready.label}`)
  395. madeProgress = true
  396. }
  397. if (running.length === 0) {
  398. const pending = allGates.filter(gate => states.get(gate.id) === 'pending')
  399. for (const gate of pending) {
  400. const failedDeps = (gate.needs ?? []).filter(id => states.get(id) !== 'passed')
  401. const result: GateResult = {
  402. gate,
  403. status: 'skipped',
  404. durationMs: 0,
  405. stdout: '',
  406. stderr: '',
  407. output: [],
  408. exitCode: null,
  409. error: `dependency failed or skipped: ${failedDeps.join(', ')}`,
  410. }
  411. states.set(gate.id, 'skipped')
  412. results.set(gate.id, result)
  413. printResult(result)
  414. }
  415. break
  416. }
  417. if (!madeProgress) {
  418. const settled = await Promise.race(running.map(async item => ({ item, result: await item.promise })))
  419. running.splice(running.indexOf(settled.item), 1)
  420. states.set(settled.item.gate.id, settled.result.status)
  421. results.set(settled.item.gate.id, settled.result)
  422. printResult(settled.result)
  423. }
  424. }
  425. return allGates.map((gate) => {
  426. const result = results.get(gate.id)
  427. if (result === undefined) throw new Error(`run-gates: missing result for ${gate.id}.`)
  428. return result
  429. })
  430. }
  431. function dependenciesPassed(gate: Gate, states: Map<string, GateStatus>): boolean {
  432. return (gate.needs ?? []).every(id => states.get(id) === 'passed')
  433. }
  434. async function runGate(gate: Gate): Promise<GateResult> {
  435. const started = performance.now()
  436. let stdout = ''
  437. let stderr = ''
  438. const output: GateOutputChunk[] = []
  439. let spawnError: string | undefined
  440. const exitCode = await new Promise<number | null>((resolveExit) => {
  441. const child = spawn(gate.command, gate.args, {
  442. cwd: root,
  443. env: { ...process.env, ...gate.env },
  444. stdio: ['pipe', 'pipe', 'pipe'],
  445. })
  446. child.stdout.setEncoding('utf8')
  447. child.stderr.setEncoding('utf8')
  448. child.stdout.on('data', (chunk: string) => {
  449. stdout += chunk
  450. output.push({ stream: 'stdout', text: chunk })
  451. })
  452. child.stderr.on('data', (chunk: string) => {
  453. stderr += chunk
  454. output.push({ stream: 'stderr', text: chunk })
  455. })
  456. child.on('error', (error) => {
  457. spawnError = `failed to start command: ${error.message}`
  458. resolveExit(null)
  459. })
  460. child.on('close', resolveExit)
  461. if (gate.input !== undefined) child.stdin.end(gate.input)
  462. else child.stdin.end()
  463. })
  464. let status: GateStatus = exitCode === 0 && spawnError === undefined ? 'passed' : 'failed'
  465. let error = spawnError
  466. if (status === 'passed' && gate.verify !== undefined) {
  467. try {
  468. await gate.verify({ gate, status, durationMs: performance.now() - started, stdout, stderr, output, exitCode })
  469. } catch (verifyError: unknown) {
  470. status = 'failed'
  471. error = verifyError instanceof Error ? verifyError.message : String(verifyError)
  472. }
  473. }
  474. const result: GateResult = {
  475. gate,
  476. status,
  477. durationMs: performance.now() - started,
  478. stdout,
  479. stderr,
  480. output,
  481. exitCode,
  482. }
  483. if (error !== undefined) result.error = error
  484. return result
  485. }
  486. function printResult(result: GateResult): void {
  487. const seconds = (result.durationMs / 1000).toFixed(2)
  488. if (result.status === 'passed' && !verbose) {
  489. console.log(`run-gates: PASS ${result.gate.label} (${seconds}s)`)
  490. return
  491. }
  492. const heading = `${result.status.toUpperCase()} ${result.gate.label} (${seconds}s)`
  493. const writeHeading = result.status === 'passed' ? console.log : console.error
  494. writeHeading(`\n== ${heading} ==`)
  495. if (result.status !== 'passed') console.error(`command: ${result.gate.displayCommand}`)
  496. printOutput(result.output)
  497. if (result.error !== undefined) console.error(result.error)
  498. }
  499. function printSummary(results: GateResult[], durationMs: number): void {
  500. const passed = results.filter(result => result.status === 'passed').length
  501. const failed = results.filter(result => result.status === 'failed').length
  502. const skipped = results.filter(result => result.status === 'skipped').length
  503. const seconds = (durationMs / 1000).toFixed(2)
  504. console.log(`\nrun-gates: ${passed} passed, ${failed} failed, ${skipped} skipped in ${seconds}s.`)
  505. const unsuccessful = results.filter(result => result.status === 'failed' || result.status === 'skipped')
  506. if (unsuccessful.length === 0) return
  507. console.error('run-gates: unsuccessful gates:')
  508. for (const result of unsuccessful) {
  509. const duration = (result.durationMs / 1000).toFixed(2)
  510. const reason = result.error ?? (result.exitCode === null ? 'no exit code' : `exit ${result.exitCode}`)
  511. console.error(` - ${result.status.toUpperCase()} ${result.gate.label} (${duration}s, ${reason})`)
  512. console.error(` ${result.gate.displayCommand}`)
  513. }
  514. }
  515. function printOutput(output: GateOutputChunk[]): void {
  516. for (const chunk of output) {
  517. if (chunk.stream === 'stdout') process.stdout.write(chunk.text)
  518. else process.stderr.write(chunk.text)
  519. }
  520. }