Skip to content

Commit ead76f4

Browse files
test-integration: the solid-query gate changes themselves (#3534)
a5219fd landed only the changeset — a stash/pop around the fast-forward dropped the index. This is the code that changeset describes: the gate packs @solidjs/compiler and @solidjs/babel-plugin, links the platform stubs, hands the built binding over via SOLID_COMPILER_NATIVE, lifts the fixture's @solidjs/vite-plugin to the root devDependency, tracks TanStack/query#solid-query-v6-pre, judges the runner by status and signal, and cleans up its tarballs; release.yml drops SKIP_SOLID_QUERY_GATE and release.mjs documents the valve. Co-authored-by: Cursor <[email protected]>
1 parent a5219fd commit ead76f4

3 files changed

Lines changed: 161 additions & 28 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ jobs:
4040
# The workspace resolves @solidjs/compiler locally, so everything that
4141
# loads it through @solidjs/vite-plugin (the examples built by
4242
# release.mjs's `pnpm run build` included) needs the binding built —
43-
# the root build script skips the Rust build.
43+
# the root build script skips the Rust build. The TanStack Solid Query
44+
# gate also hands this binding to the compiler it packs (#3534).
4445
- uses: dtolnay/rust-toolchain@stable
4546
- uses: Swatinem/rust-cache@v2
4647
with:
@@ -60,11 +61,10 @@ jobs:
6061
env:
6162
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6263
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
# rc.9 moves delegated events to the `_$$<type>` key; the solid-query
64-
# fixture's published compiler still emits `$$<type>`, so the gate
65-
# cannot pass until rc.9 itself ships (see scripts/release.mjs).
66-
# Expires with this version — leave it until the fixture is bumped.
67-
SKIP_SOLID_QUERY_GATE: 2.0.0-rc.9
64+
# Emergency valve for the TanStack Solid Query gate: set to the exact
65+
# version being released to let that ONE release through without it
66+
# (see scripts/release.mjs). Self-expiring; remove after the release.
67+
# SKIP_SOLID_QUERY_GATE: 2.0.0-rc.N
6868

6969
# Installs the just-published packages from the real registry into a temp
7070
# project and exercises them (dist-tags, native compiler binary, runtime).

‎packages/test-integration/tests/tanstack-solid-query.spec.ts‎

Lines changed: 148 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1-
import { beforeAll, describe, expect, test } from "vitest";
1+
import { afterAll, beforeAll, describe, expect, test } from "vitest";
22
import { exec, mkdir, rm } from "shelljs";
33
import { download, extract } from "gitly";
4-
import { appendFileSync, existsSync, readFileSync, realpathSync, writeFileSync } from "fs";
4+
import {
5+
appendFileSync,
6+
existsSync,
7+
readFileSync,
8+
readdirSync,
9+
realpathSync,
10+
statSync,
11+
writeFileSync
12+
} from "fs";
513
import { join, resolve } from "path";
14+
import { spawnSync } from "child_process";
615

716
/**
817
* Release gate: the TanStack Solid Query adapter's full suite against the
918
* WORKSPACE-BUILT core — solid-js, @solidjs/signals, and @solidjs/web packed
10-
* from this tree and installed together, never a registry mix.
19+
* from this tree and installed together, never a registry mix — compiled by
20+
* the WORKSPACE-BUILT compiler (@solidjs/compiler with this tree's native
21+
* binding, @solidjs/babel-plugin), never the registry's.
22+
*
23+
* Both halves matter. Compiled output and runtime are one contract: rc.9
24+
* moved delegated event handlers to the `_$$<type>` key, and against the
25+
* fixture's published compiler (still emitting `$$<type>`) every click in
26+
* the suite was a no-op — 95 failures, none of them adapter semantics, and
27+
* circular: the fixture could not pick up the new compiler until the
28+
* release was on npm, and the gate blocked the release (#3534).
1129
*
1230
* This exists because core-side suites structurally cannot protect the
1331
* adapter contract. The rc.5 regression (#3181's fix waking parked readers
@@ -27,14 +45,35 @@ import { join, resolve } from "path";
2745

2846
// The ref the gate tracks — overridable for one-off runs via
2947
// SOLID_QUERY_GATE_REPO. The question a release must answer is "does OUR
30-
// next core break the adapter people will install alongside it". Today that
31-
// adapter lives on the PR branch carrying the Solid 2.0 pairing
32-
// (TanStack/query#11326: named flight source, @solidjs/vite-plugin, the
33-
// solid-js/web alias its vitest config needs to run against a 2.0 core);
34-
// flip this to "TanStack/query" once it merges.
35-
const QUERY_REPO = process.env.SOLID_QUERY_GATE_REPO ?? "ryansolid/query#feat/flight-data-source";
48+
// next core break the adapter people will install alongside it". That
49+
// adapter is @tanstack/solid-query 6 (the `rc` dist-tag), developed and
50+
// released from TanStack's `solid-query-v6-pre` branch — the Solid 2.0
51+
// pairing (TanStack/query#11326) merged there, not `main`, which still
52+
// carries the Solid 1.x adapter. Flip to "TanStack/query" when v6 lands on
53+
// main.
54+
const QUERY_REPO = process.env.SOLID_QUERY_GATE_REPO ?? "TanStack/query#solid-query-v6-pre";
3655

3756
const CORE_PACKAGES = ["signals", "solid", "web"] as const;
57+
// The compiler side of the contract. The fixture's @solidjs/vite-plugin
58+
// loads both: @solidjs/compiler in every mode (lazy/refresh/server-function
59+
// passes and, by default, JSX), @solidjs/babel-plugin for `compiler: "babel"`.
60+
const COMPILER_PACKAGES = ["compiler", "babel-plugin"] as const;
61+
// @solidjs/compiler's optionalDependencies pin platform binaries to THIS
62+
// version, which reaches the registry only after release.mjs publishes them
63+
// — after this gate. Resolve them to the in-repo stubs (no .node inside),
64+
// exactly as the workspace's own pnpm-workspace.yaml does, and hand the
65+
// loader the locally built binding through SOLID_COMPILER_NATIVE.
66+
const COMPILER_PLATFORMS = [
67+
"darwin-x64",
68+
"darwin-arm64",
69+
"linux-x64-gnu",
70+
"linux-arm64-gnu",
71+
"win32-x64-msvc",
72+
"wasm32-wasi"
73+
] as const;
74+
75+
const repoRoot = resolve(join(__dirname, "../../.."));
76+
const packageRoot = (dir: string) => join(repoRoot, "packages", dir);
3877

3978
function pack(packageRoot: string) {
4079
const pkg = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8"));
@@ -43,19 +82,75 @@ function pack(packageRoot: string) {
4382
return { name: pkg.name as string, path: join(packageRoot, packedPkg) };
4483
}
4584

85+
// Newest mtime under a directory tree — the honest "when was this last
86+
// touched" for a source folder.
87+
function newestMtime(dir: string): number {
88+
let newest = 0;
89+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
90+
const full = join(dir, entry.name);
91+
const mtime = entry.isDirectory() ? newestMtime(full) : statSync(full).mtimeMs;
92+
if (mtime > newest) newest = mtime;
93+
}
94+
return newest;
95+
}
96+
97+
// The native binding `pnpm --filter @solidjs/compiler run build` leaves next
98+
// to index.js, in the loader's own preference order. The published package
99+
// ships no local binary (see its "files"), so the packed tarball needs this
100+
// handed to it explicitly.
101+
function locateCompilerBinding(): string {
102+
const compilerDir = packageRoot("compiler");
103+
const { platform, arch } = process;
104+
const suffix =
105+
platform === "darwin" && (arch === "x64" || arch === "arm64")
106+
? `darwin-${arch}`
107+
: platform === "linux" && (arch === "x64" || arch === "arm64")
108+
? `linux-${arch}-gnu`
109+
: platform === "win32" && arch === "x64"
110+
? "win32-x64-msvc"
111+
: null;
112+
const candidates = suffix ? [`compiler.${suffix}.node`, "compiler.node"] : ["compiler.node"];
113+
const found = candidates.map(file => join(compilerDir, file)).find(existsSync);
114+
if (!found) {
115+
throw new Error(
116+
"packages/compiler has no native binding. Run `pnpm --filter @solidjs/compiler run build` first."
117+
);
118+
}
119+
// A binding older than the compiler's sources would silently gate the
120+
// release on the previous compiler — the exact failure this gate exists
121+
// to catch. (CI builds it in the release job; this guards local runs.)
122+
if (statSync(found).mtimeMs < newestMtime(join(compilerDir, "src"))) {
123+
throw new Error(
124+
`${found} is older than packages/compiler/src. Rebuild with \`pnpm --filter @solidjs/compiler run build\`.`
125+
);
126+
}
127+
return found;
128+
}
129+
46130
describe("TanStack Solid Query against workspace-built core", () => {
47131
const queryRepoDir = resolve(
48132
join(__dirname, "fixtures", "downloaded", QUERY_REPO.replace(/[#/]/g, "-"))
49133
);
50-
let tarballs: Array<{ name: string; path: string }>;
134+
let tarballs: Array<{ name: string; path: string }> = [];
135+
let compilerBinding: string;
136+
137+
// The tarballs are packed into their package directories (untracked
138+
// there); pnpm has copied them into its store by the time the suite ran.
139+
afterAll(() => {
140+
for (const { path } of tarballs) rm("-f", path);
141+
});
51142

52143
beforeAll(async () => {
53144
for (const dir of CORE_PACKAGES) {
54-
if (!existsSync(resolve(join(__dirname, `../../${dir}/dist`)))) {
145+
if (!existsSync(join(packageRoot(dir), "dist"))) {
55146
throw new Error(`packages/${dir} is not built. Run \`pnpm build\` first.`);
56147
}
57148
}
58-
tarballs = CORE_PACKAGES.map(dir => pack(resolve(join(__dirname, `../../${dir}`))));
149+
if (!existsSync(join(packageRoot("babel-plugin"), "index.js"))) {
150+
throw new Error("packages/babel-plugin is not built. Run `pnpm build` first.");
151+
}
152+
compilerBinding = locateCompilerBinding();
153+
tarballs = [...CORE_PACKAGES, ...COMPILER_PACKAGES].map(dir => pack(packageRoot(dir)));
59154

60155
// Fresh download every run: the gate must see TanStack's current main,
61156
// and a stale extraction with a mutated lockfile would poison reruns.
@@ -72,7 +167,21 @@ describe("TanStack Solid Query against workspace-built core", () => {
72167
// pnpm.overrides is silently ignored there — measured, not assumed).
73168
const workspaceYamlPath = join(queryRepoDir, "pnpm-workspace.yaml");
74169
const workspaceYaml = readFileSync(workspaceYamlPath, "utf8");
75-
const overrideLines = tarballs.map(t => ` '${t.name}': 'file:${t.path}'`).join("\n");
170+
// The fixture's own @solidjs/vite-plugin predates the switch from
171+
// @dom-expressions/compiler to @solidjs/compiler; older plugins ignore the
172+
// packed compiler entirely. Lift it to the plugin this tree is tested
173+
// with — the root devDependency, one source of truth — so the fixture is
174+
// compiled through the same plugin the examples and suites use.
175+
const vitePluginVersion = JSON.parse(readFileSync(join(repoRoot, "package.json"), "utf8"))
176+
.devDependencies["@solidjs/vite-plugin"];
177+
expect(vitePluginVersion, "root devDependency @solidjs/vite-plugin").toBeTruthy();
178+
const overrideLines = [
179+
...tarballs.map(t => ` '${t.name}': 'file:${t.path}'`),
180+
...COMPILER_PLATFORMS.map(
181+
p => ` '@solidjs/compiler-${p}': 'link:${join(packageRoot("compiler"), "npm", p)}'`
182+
),
183+
` '@solidjs/vite-plugin': '${vitePluginVersion}'`
184+
].join("\n");
76185
if (/^overrides:/m.test(workspaceYaml)) {
77186
writeFileSync(
78187
workspaceYamlPath,
@@ -112,13 +221,37 @@ describe("TanStack Solid Query against workspace-built core", () => {
112221
// nothing the registry could poison. When present it must be ours.
113222
const webLink = join(solidQueryDir, "node_modules", "@solidjs", "web");
114223
if (existsSync(webLink)) fromTarball(webLink, "@solidjs/web");
224+
// The compiler pair is requested by @solidjs/vite-plugin, not by
225+
// solid-query, so probe it through the plugin's own resolution — the
226+
// path the fixture's vite config actually loads.
227+
const vitePluginReal = realpathSync(
228+
join(solidQueryDir, "node_modules", "@solidjs", "vite-plugin")
229+
);
230+
expect(
231+
JSON.parse(readFileSync(join(vitePluginReal, "package.json"), "utf8")).version,
232+
"@solidjs/vite-plugin was not lifted to the workspace's version"
233+
).toBe(vitePluginVersion);
234+
// (vitePluginReal is `<store>/node_modules/@solidjs/vite-plugin`; its
235+
// dependencies are siblings under the same scope directory.)
236+
for (const name of ["@solidjs/compiler", "@solidjs/babel-plugin"]) {
237+
fromTarball(join(vitePluginReal, "..", name.slice("@solidjs/".length)), name);
238+
}
115239

116240
// The suite's typecheck half resolves @tanstack/query-core through
117241
// project references — dist-ts must exist (`tsc --build` follows the
118242
// reference graph).
119243
exec("pnpm run compile", { cwd: solidQueryDir, fatal: true });
120244

121-
const result = exec("npx vitest run", { cwd: solidQueryDir, fatal: false });
122-
expect(result.code).toBe(0);
245+
// spawnSync, not shelljs: a runner that dies on a signal (V8's heap OOM
246+
// aborts) has no exit code, and shelljs reported that as 0 — a crashed
247+
// suite read as green. Judge the exit and the signal separately.
248+
const result = spawnSync("npx", ["vitest", "run"], {
249+
cwd: solidQueryDir,
250+
stdio: "inherit",
251+
env: { ...process.env, SOLID_COMPILER_NATIVE: compilerBinding }
252+
});
253+
expect(result.error, "vitest could not be started").toBeUndefined();
254+
expect(result.signal, "vitest was killed by a signal").toBeNull();
255+
expect(result.status, "vitest exit status").toBe(0);
123256
}, 900_000);
124257
});

‎scripts/release.mjs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ run("node", ["scripts/verify-release-artifacts.mjs"]);
103103
// suite could see) — a release candidate that breaks the flagship adapter
104104
// must fail here, not on npm.
105105
//
106-
// The gate swaps in the workspace *runtime* but compiles the adapter with the
107-
// fixture's published compiler, so a release that changes the compiled-output
108-
// contract (rc.9: delegated events moved to the `_$$<type>` key) cannot pass
109-
// until that compiler is itself on npm — circular. SKIP_SOLID_QUERY_GATE names
110-
// the one version allowed through without it, so the skip expires with that
111-
// release; the follow-up is for the gate to pack the workspace compiler
112-
// alongside the core (#3534).
106+
// The gate packs this tree's compiler (@solidjs/compiler with the binding
107+
// built above, @solidjs/babel-plugin) alongside the core, so compiled output
108+
// and runtime are always the same release (#3534). A failure here is the
109+
// adapter disagreeing with this release's semantics. SKIP_SOLID_QUERY_GATE is
110+
// the emergency valve: it names the ONE version allowed through without the
111+
// gate, so a skip expires with that release and must be set deliberately in
112+
// release.yml — never left on.
113113
const coreVersion = JSON.parse(
114114
fs.readFileSync(new URL("../packages/solid/package.json", import.meta.url), "utf8")
115115
).version;

0 commit comments

Comments
 (0)