pnpm run build ran every step in one serial chain, including the two noEmit aggregate programs (tests, scripts, benchmarks, website) that no artifact step consumes, so the Host aggregate check alone delayed tsdown by about 66 s. - build:src (scripts/build.ts --scope src) builds every artifact in the existing order and writes the client build record; it replaces the removed --artifacts-only flag and the libraries CLI mode. - build:test (--scope test) type-checks only the Host and Client aggregate programs with tsc -p, concurrently, without compiling references or checking prerequisites. - build runs both as one dependency graph through run-gates' new runAggregate: each aggregate check starts once its face's packages are compiled, and Client compilation stays after the Host bundle that writes the Typert /remote declarations. DSH_GATE_CONCURRENCY=1 serializes it; DSH_GATE_FAIL_FAST=1 stops the remaining steps at the first failure. Passing steps print one PASS line (DSH_GATE_VERBOSE=1 shows their output). - PR artifact builds (e2e, release, preview, Node 22 compatibility) and the Python builder (--build-src) use build:src; dev:web and dev:desktop use build:src. test:*, bench, typecheck and the required consumer/Windows lanes keep the complete build. - lint, lint:fix, doc-typecheck and the Typert contracts gate prepare with host-libraries (Host package compilation + Host bundle) instead of build:lib:host; their own checks never read the aggregate root or the Desktop bundle. Parallel and serial build produce byte-identical lib/, Web dist and client build record; a test-only type error fails build and build:test while build:src passes. Refs #5852
83 lines
3.3 KiB
TypeScript
83 lines
3.3 KiB
TypeScript
import { spawnSync } from 'node:child_process'
|
|
import { resolve } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { buildGates, parseBuildArguments } from './build.ts'
|
|
|
|
const root = resolve(import.meta.dirname, '..')
|
|
|
|
function graph(scope: Parameters<typeof buildGates>[1]): Record<string, string[] | undefined> {
|
|
return Object.fromEntries(buildGates(root, scope).map(gate => [gate.id, gate.needs]))
|
|
}
|
|
|
|
describe('repository build CLI', () => {
|
|
// The sentinel makes parseArgs fail fast if the check ever stops running first.
|
|
it('rejects a Node process without TypeScript type stripping before any build step', () => {
|
|
const result = spawnSync(
|
|
process.execPath,
|
|
['--no-experimental-strip-types', '--import', 'tsx/esm', resolve(root, 'scripts/build.ts'), '--spec-sentinel'],
|
|
{ cwd: root, encoding: 'utf8' },
|
|
)
|
|
expect(result.status).not.toBe(0)
|
|
expect(result.stderr).toContain('build: Node.js TypeScript type stripping is unavailable')
|
|
})
|
|
|
|
it('rejects the removed artifacts-only flag before any build step', () => {
|
|
const result = spawnSync(
|
|
process.execPath,
|
|
['--import', 'tsx/esm', resolve(root, 'scripts/build.ts'), '--artifacts-only'],
|
|
{ cwd: root, encoding: 'utf8' },
|
|
)
|
|
expect(result.status).not.toBe(0)
|
|
expect(result.stderr).toContain("Unknown option '--artifacts-only'")
|
|
})
|
|
|
|
it('selects the complete build by default and one step set by scope', () => {
|
|
expect(parseBuildArguments([])).toEqual({ scope: 'complete', profile: undefined })
|
|
expect(parseBuildArguments(['--scope', 'src', '--profile', 'official'])).toEqual({ scope: 'src', profile: 'official' })
|
|
expect(parseBuildArguments(['--scope', 'test'])).toEqual({ scope: 'test', profile: undefined })
|
|
})
|
|
|
|
it.each([
|
|
[['--scope', 'complete'], '--scope must be src or test'],
|
|
[['--scope', 'lib'], '--scope must be src or test'],
|
|
[['--scope', 'test', '--profile', 'official'], '--profile selects artifact values and does not apply to --scope test'],
|
|
])('rejects %j', (args, message) => {
|
|
expect(() => parseBuildArguments(args)).toThrow(message)
|
|
})
|
|
})
|
|
|
|
describe('repository build steps', () => {
|
|
it('keeps artifact steps in serial dependency order', () => {
|
|
expect(graph('src')).toEqual({
|
|
'native': [],
|
|
'host-src': ['native'],
|
|
'host-bundle': ['host-src'],
|
|
'desktop-bundle': ['host-bundle'],
|
|
'client-src': ['desktop-bundle'],
|
|
'client-bundle': ['client-src'],
|
|
'web': ['client-bundle'],
|
|
})
|
|
})
|
|
|
|
it('checks both aggregate programs without artifact predecessors', () => {
|
|
expect(graph('test')).toEqual({ 'host-test': [], 'client-test': [] })
|
|
expect(buildGates(root, 'test').map(gate => gate.args.slice(-2))).toEqual([
|
|
['-p', 'tsconfig.host.json'],
|
|
['-p', 'tsconfig.client.json'],
|
|
])
|
|
})
|
|
|
|
it('starts each aggregate check after its own package compilation in the complete build', () => {
|
|
expect(graph('complete')).toEqual({
|
|
...graph('src'),
|
|
'host-test': ['host-src'],
|
|
'client-test': ['client-src'],
|
|
})
|
|
})
|
|
|
|
it('applies the environment overlay to every step', () => {
|
|
const environment = { DSH_CLIENT_TITLE: 'Title', DSH_BUILD_CLIENT_PROFILE: undefined }
|
|
for (const gate of buildGates(root, 'complete', environment)) expect(gate.env).toEqual(environment)
|
|
})
|
|
})
|