mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
- test:changed exits before starting Vitest when Git reports no changed files. - Unrecorded tests beyond 100 in scope use Vitest's static import graph instead of all running, so a fresh worktree's first changed run no longer runs the whole suite (patched RecordedModulesResolver; CI does not record, unchanged). - Bun's slow config load was the SQLite import scan statting every unit test; filtered runs now classify only the tests their filters can select, and the scan walks directories instead of fs.globSync. - Silence the native config loader notice on every run. - Zod's test bundle is content-addressed and reused, so a killed run leaks nothing; leaked per-run directories older than 6h are swept. - build:packages skips compiling when package inputs, compiler, and dist are unchanged; test scripts no longer nest pnpm invocations.
59 lines
1.9 KiB
JavaScript
59 lines
1.9 KiB
JavaScript
import { resolve } from 'node:path'
|
|
import { runProcess, runProcessSync } from '@orca/process-host'
|
|
import { hasNoChangedFiles } from './vitest-changed-precheck.mjs'
|
|
import { RUN_ARGS_ENV } from './vitest-run-filters.mjs'
|
|
import { createVitestZodBundle } from './vitest-zod-bundle.mjs'
|
|
import {
|
|
checkBunVersion,
|
|
probeBunVersion,
|
|
readPinnedBunVersion,
|
|
resolvePinnedBunExecutable
|
|
} from './pinned-bun-executable.mjs'
|
|
|
|
const root = resolve(import.meta.dirname, '../..')
|
|
const vitestArgs = process.argv.slice(2)
|
|
|
|
function runVitest() {
|
|
const pinnedBun = resolvePinnedBunExecutable(root, runProcessSync)
|
|
const bunCheck = pinnedBun
|
|
? { ok: true }
|
|
: checkBunVersion(probeBunVersion('bun', root, runProcessSync), readPinnedBunVersion(root))
|
|
if (bunCheck.message) {
|
|
console.error(bunCheck.message)
|
|
}
|
|
if (!bunCheck.ok) {
|
|
return 1
|
|
}
|
|
try {
|
|
const zodBundle = createVitestZodBundle(root)
|
|
const result = runProcessSync({
|
|
program: pinnedBun ?? 'bun',
|
|
args: ['--bun', resolve(root, 'node_modules/vitest/vitest.mjs'), ...vitestArgs],
|
|
cwd: root,
|
|
env: {
|
|
...process.env,
|
|
ORCA_BACKGROUND_LAUNCH: '1',
|
|
ORCA_TEST_NODE_EXECUTABLE: process.execPath,
|
|
ORCA_TEST_NODE_VERSION: process.versions.node,
|
|
ORCA_UNIT_ZOD_BUNDLE: zodBundle.path,
|
|
[RUN_ARGS_ENV]: JSON.stringify(vitestArgs),
|
|
// The config's TypeScript and CommonJS package scope are intended; the notice is noise.
|
|
VITE_CONFIG_NATIVE_IGNORE_WARNING: 'true'
|
|
},
|
|
stdio: 'inherit',
|
|
timeoutMs: null
|
|
})
|
|
return result.code ?? 1
|
|
} catch (error) {
|
|
console.error('Could not prepare or start Vitest:', error)
|
|
return 1
|
|
}
|
|
}
|
|
|
|
if (await hasNoChangedFiles(vitestArgs, root, runProcess)) {
|
|
// Vitest's own result for this case, without paying its startup.
|
|
console.log('No changed files found, exiting with code 0')
|
|
} else {
|
|
process.exitCode = runVitest()
|
|
}
|