mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-09 04:02:35 +00:00
A developer's Clash and a CI runner's squid both export HTTP_PROXY and its siblings. Now that the harness honors them, an ambient value decides test outcomes: this PR has already recorded a proxy's 502 page as a snapshot's expected output, and let a runner's own export stand in for "what the user exported" in an assertion about inherited names. A Vitest setup file clears the proxy names before any suite runs, wired into every configuration that declares a setup. Real-API e2e is cleared too: before proxy support existed every request connected directly and that suite passed, so direct is the environment it is known to work in. `NODE_USE_ENV_PROXY` cannot be cleared this way — Node samples the proxy environment at process start — and the module says so. A proxy application never exports it, and the eight names one does export are fully handled: with all of them set, the affected suites pass. The wiring is what regresses, so that is what the test pins. Configurations are discovered rather than listed, because the web suites carry no setup today and a hand-written list would let one of them gain a setup without gaining this one. `plugin.spec.ts` kept its own copy of the eight names to guard against the machine; it never sets a proxy variable itself, so the setup replaces that entirely. `install.spec.ts` had one assertion waiting on a DNS miss with no deadline, which timed out once under load.
63 lines
2.7 KiB
TypeScript
63 lines
2.7 KiB
TypeScript
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
import { defineConfig } from 'vitest/config'
|
|
import { standardDecoratorPlugin, vitestExecArgv } from './vitest.shared.ts'
|
|
|
|
// Real-API suite, separate because it spends tokens. Each test self-skips without
|
|
// its provider credential for keyless CI; credentialed workflows preflight the
|
|
// secrets they require. Values may come from the environment or gitignored root
|
|
// `.env`, with provider-specific endpoint overrides where supported.
|
|
try {
|
|
// Node >= 21.7 native; throws when the file does not exist.
|
|
process.loadEnvFile(new URL('.env', import.meta.url).pathname)
|
|
} catch {
|
|
// No .env — fine, the environment may already carry the variables.
|
|
}
|
|
|
|
const DEFAULT_E2E_MAX_WORKERS = 4
|
|
|
|
function positiveIntFromEnv(name: string, fallback: number): number {
|
|
const raw = process.env[name]
|
|
if (raw === undefined || raw === '') return fallback
|
|
|
|
const value = Number(raw)
|
|
if (!Number.isInteger(value) || value < 1) {
|
|
throw new Error(`${name} must be a positive integer, got ${JSON.stringify(raw)}`)
|
|
}
|
|
return value
|
|
}
|
|
|
|
const e2eMaxWorkers = positiveIntFromEnv('DSH_E2E_MAX_WORKERS', DEFAULT_E2E_MAX_WORKERS)
|
|
|
|
export default defineConfig({
|
|
// Same resolution note as vitest.config.ts: bare workspace names resolve
|
|
// through the tsconfig.base.json paths facade (no include = match-all, so
|
|
// client-package sources get mapping too — dropping /client subpath imports
|
|
// onto package exports would load browser dist bundles into node).
|
|
// Built-artifact e2e suites are unaffected: their built-ness lives in
|
|
// subprocesses and createRequire lookups, which bypass vite resolution
|
|
// entirely.
|
|
plugins: [tsconfigPaths({ projects: ['./tsconfig.base.json'] }), standardDecoratorPlugin()],
|
|
test: {
|
|
execArgv: vitestExecArgv,
|
|
setupFiles: ['./scripts/test-proxy-environment.ts', './scripts/test-invariants.ts'],
|
|
// apps/cli only, not apps/*: apps/web/tests/*.e2e.ts needs the built
|
|
// frontend dist and runs under vitest.web.config.ts (the test:web job).
|
|
include: ['packages/*/*/tests/**/*.e2e.ts', 'apps/cli/tests/**/*.e2e.ts'],
|
|
exclude: [
|
|
'**/*.expected.e2e.ts',
|
|
'packages/experimental/inspector/tests/client-browser.e2e.ts',
|
|
],
|
|
// Real model calls: generous timeouts, and retries for transient flakes
|
|
// (the shared internal key hits concurrency quotas). No coverage — the
|
|
// unit suites own the coverage gate.
|
|
testTimeout: 120_000,
|
|
hookTimeout: 30_000,
|
|
retry: 2,
|
|
// Run files in a bounded pool: enough lower-level parallelism to keep CI
|
|
// and local with-key runs moving, while leaving a resource knob for shared
|
|
// API quotas (`DSH_E2E_MAX_WORKERS=1` restores serial execution).
|
|
fileParallelism: e2eMaxWorkers > 1,
|
|
maxWorkers: e2eMaxWorkers,
|
|
},
|
|
})
|