mirror of
https://github.com/Effect-TS/effect.git
synced 2026-12-03 03:25:40 +08:00
Share the root Vite server across Vitest projects (#11250)
This commit is contained in:
@@ -166,10 +166,9 @@ jobs:
|
||||
node: ""
|
||||
deno: ""
|
||||
bun: ""
|
||||
# The full suite exceeds Node's default ~2 GiB heap on this runner.
|
||||
# The effect/ui suites run in jobs of their own below, as one run of
|
||||
# everything exceeds this runner's memory.
|
||||
command: EFFECT_UI_TESTS=0 NODE_OPTIONS=--max-old-space-size=4096 pnpm test --max-concurrency=10
|
||||
command: EFFECT_UI_TESTS=0 pnpm test --max-concurrency=10
|
||||
# Node 25 and older handle upgrade request bodies differently.
|
||||
- runtime: Node 24 (platform-node)
|
||||
node: 24
|
||||
|
||||
+43
-59
@@ -17,30 +17,27 @@ const clusterTestsEnabled = process.env.EFFECT_CLUSTER_TESTS === "1"
|
||||
// process of their own and keep each run's memory within its runner.
|
||||
const uiTestsEnabled = process.env.EFFECT_UI_TESTS !== "0"
|
||||
|
||||
// Use `test.dir` to share the root Vite server and transform cache.
|
||||
// Projects that override Vite options get their own server.
|
||||
const project = (
|
||||
name: string,
|
||||
directory: string,
|
||||
include: boolean = true,
|
||||
config: ViteUserConfig = {},
|
||||
projectExclude?: ReadonlyArray<string>,
|
||||
projectInclude?: ReadonlyArray<string>
|
||||
config: ViteUserConfig = {}
|
||||
) => {
|
||||
if (!include) {
|
||||
return []
|
||||
}
|
||||
|
||||
const cfg = mergeConfig({
|
||||
root: directory,
|
||||
test: { name }
|
||||
const merged = mergeConfig({
|
||||
test: {
|
||||
name,
|
||||
dir: path.join(import.meta.dirname, directory)
|
||||
}
|
||||
}, config)
|
||||
|
||||
const merged = mergeConfig(shared, cfg)
|
||||
if (projectExclude !== undefined) {
|
||||
merged.test!.exclude = [...projectExclude]
|
||||
}
|
||||
if (projectInclude !== undefined) {
|
||||
merged.test!.include = [...projectInclude]
|
||||
}
|
||||
// Apply defaults here because mergeConfig concatenates arrays.
|
||||
merged.test!.include ??= ["test/**/*.test.{ts,tsx}"]
|
||||
merged.test!.exclude ??= [...exclude]
|
||||
return [merged]
|
||||
}
|
||||
|
||||
@@ -72,7 +69,7 @@ const effectIsolatedTests = [
|
||||
"test/ui/kit/**/*.test.ts"
|
||||
]
|
||||
|
||||
const shared: ViteUserConfig = {
|
||||
export default defineConfig({
|
||||
optimizeDeps: {
|
||||
exclude: ["bun:sqlite"]
|
||||
},
|
||||
@@ -85,54 +82,45 @@ const shared: ViteUserConfig = {
|
||||
tsconfigPaths: true
|
||||
},
|
||||
test: {
|
||||
exclude,
|
||||
passWithNoTests: true,
|
||||
setupFiles: [path.join(import.meta.dirname, "vitest.setup.ts")],
|
||||
sequence: {
|
||||
concurrent: true
|
||||
},
|
||||
include: ["test/**/*.test.{ts,tsx}"],
|
||||
coverage: {
|
||||
provider: "v8",
|
||||
reporter: ["html"],
|
||||
reportsDirectory: "coverage",
|
||||
exclude
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
passWithNoTests: true,
|
||||
},
|
||||
// The shared cluster storage suite runs MSSQL alongside the other databases.
|
||||
...(mssqlIntegrationTestsDisabled ? { testNamePattern: /^(?!.*SqlMessageStorage > mssql > )/ } : {}),
|
||||
projects: [
|
||||
...project("scripts", "scripts", true, {}, undefined, ["codemods/jsdoc.test.ts"]),
|
||||
...project("scripts", "scripts", true, { test: { include: ["codemods/jsdoc.test.ts"] } }),
|
||||
// Node reuses workers across effect test files, which skips re-importing
|
||||
// the effect module graph for every file.
|
||||
...project(
|
||||
"effect",
|
||||
"packages/effect",
|
||||
true,
|
||||
{ test: { isolate: !isNode } },
|
||||
[
|
||||
...exclude,
|
||||
...effectIsolatedTests,
|
||||
...(isBun
|
||||
? [
|
||||
// These tests assert Node-specific Web API or stack trace behavior.
|
||||
"test/reactivity/Atom.test.ts",
|
||||
"test/schema/Schema.test.ts",
|
||||
"test/schema/SchemaGetter.test.ts",
|
||||
"test/schema/toCodec.test.ts",
|
||||
"test/schema/toDifferJsonPatch.test.ts",
|
||||
"test/http/HttpEffect.test.ts",
|
||||
"test/http/HttpServerRequest.test.ts"
|
||||
]
|
||||
: [])
|
||||
]
|
||||
),
|
||||
...project("effect-isolated", "packages/effect", true, {}, undefined, effectIsolatedTests),
|
||||
...project("effect", "packages/effect", true, {
|
||||
test: {
|
||||
isolate: !isNode,
|
||||
exclude: [
|
||||
...exclude,
|
||||
...effectIsolatedTests,
|
||||
...(isBun
|
||||
? [
|
||||
// These tests assert Node-specific Web API or stack trace behavior.
|
||||
"test/reactivity/Atom.test.ts",
|
||||
"test/schema/Schema.test.ts",
|
||||
"test/schema/SchemaGetter.test.ts",
|
||||
"test/schema/toCodec.test.ts",
|
||||
"test/schema/toDifferJsonPatch.test.ts",
|
||||
"test/http/HttpEffect.test.ts",
|
||||
"test/http/HttpServerRequest.test.ts"
|
||||
]
|
||||
: [])
|
||||
]
|
||||
}
|
||||
}),
|
||||
...project("effect-isolated", "packages/effect", true, { test: { include: effectIsolatedTests } }),
|
||||
...project("@effect/ai-amazon-bedrock", "packages/ai/amazon-bedrock"),
|
||||
...project("@effect/ai-anthropic", "packages/ai/anthropic"),
|
||||
...project("@effect/ai-cloudflare", "packages/ai/cloudflare"),
|
||||
@@ -172,9 +160,10 @@ export default defineConfig({
|
||||
// The UI host packages run on Node: NativeVitest needs Node's module hooks and OpenTUI needs its FFI.
|
||||
...project("@effect/ui-devtools", "packages/ui/devtools", isNode && uiTestsEnabled),
|
||||
...project("@effect/ui-native", "packages/ui/native", isNode && uiTestsEnabled, {
|
||||
// NativeVitest and the relative setup file resolve from the Vite root.
|
||||
root: "packages/ui/native",
|
||||
plugins: [NativeVitest.plugin()],
|
||||
// A setup file loading the kit, in order, checks that the plugin's
|
||||
// hooks are installed before any setup file runs.
|
||||
// Load the kit during setup to check that the plugin's hooks are already installed.
|
||||
test: {
|
||||
setupFiles: ["test/utils/setup.ts"],
|
||||
sequence: { setupFiles: "list" }
|
||||
@@ -214,17 +203,14 @@ export default defineConfig({
|
||||
path.join(import.meta.dirname, "packages/platform/node/test/cluster-integration/globalSetup.ts")
|
||||
],
|
||||
include: ["test/cluster-integration/**/*.test.ts"],
|
||||
exclude: exclude.filter((path) => path !== "**/test/cluster-integration/**"),
|
||||
retry: 0,
|
||||
sequence: {
|
||||
concurrent: false
|
||||
},
|
||||
testTimeout: 60_000
|
||||
}
|
||||
},
|
||||
exclude.filter((path) => path !== "**/test/cluster-integration/**"),
|
||||
[
|
||||
"test/cluster-integration/**/*.test.ts"
|
||||
]
|
||||
}
|
||||
),
|
||||
...project("@effect/platform-node-shared", "packages/platform/node-shared", isNode),
|
||||
...project("@effect/vitest", "packages/vitest"),
|
||||
@@ -235,8 +221,7 @@ export default defineConfig({
|
||||
"@effect/sql-mssql",
|
||||
"packages/sql/mssql",
|
||||
true,
|
||||
{},
|
||||
mssqlIntegrationTestsDisabled ? [...exclude, "**/*.integration.test.{ts,tsx}"] : undefined
|
||||
mssqlIntegrationTestsDisabled ? { test: { exclude: [...exclude, "**/*.integration.test.{ts,tsx}"] } } : {}
|
||||
),
|
||||
...project(
|
||||
"@effect/sql-mysql2",
|
||||
@@ -253,9 +238,8 @@ export default defineConfig({
|
||||
"@effect/sql-sqlite-do",
|
||||
"packages/sql/sqlite-do",
|
||||
true,
|
||||
{},
|
||||
// Miniflare needs Node/Bun; keep the in-process client tests on Deno.
|
||||
isDeno ? [...exclude, "test/Miniflare.test.ts"] : undefined
|
||||
isDeno ? { test: { exclude: [...exclude, "test/Miniflare.test.ts"] } } : {}
|
||||
),
|
||||
...project("@effect/sql-sqlite-node", "packages/sql/sqlite-node", isNode || isDeno),
|
||||
...project("@effect/sql-sqlite-react-native", "packages/sql/sqlite-react-native"),
|
||||
|
||||
Reference in New Issue
Block a user