build(client): use locked uv environment in launcher and Docker
This commit is contained in:
@@ -66,14 +66,19 @@ async function launcher(context: TestContext, env: Record<string, string> = {})
|
||||
const root = await mkdtemp(join(tmpdir(), "s2s-launcher-"));
|
||||
const frontend = join(root, "s2s-frontend");
|
||||
const modules = join(frontend, "node_modules");
|
||||
await mkdir(join(root, ".venv/bin"), { recursive: true });
|
||||
await mkdir(join(root, "s2s-client"));
|
||||
await mkdir(join(root, "s2s-client/.venv/bin"), { recursive: true });
|
||||
await mkdir(join(root, "bin"));
|
||||
await mkdir(join(modules, "vite/bin"), { recursive: true });
|
||||
await copyFile(new URL("../../start_ui.sh", import.meta.url), join(root, "start_ui.sh"));
|
||||
await writeFile(join(root, "s2s-client/requirements.txt"), "");
|
||||
await writeFile(join(root, ".venv/bin/activate"), 'export PATH="$S2S_TEST_ROOT/.venv/bin:$PATH"\n');
|
||||
await writeFile(join(root, "s2s-client/pyproject.toml"), "");
|
||||
await writeFile(join(root, "s2s-client/uv.lock"), "");
|
||||
await writeFile(
|
||||
join(root, ".venv/bin/python"),
|
||||
join(root, "bin/uv"),
|
||||
'#!/bin/bash\nprintf "%s\\n" "$@" > "$S2S_TEST_ROOT/uv-args"\nprintf "%s" "$UV_PROJECT_ENVIRONMENT" > "$S2S_TEST_ROOT/uv-environment"\nexit "${S2S_TEST_UV_EXIT:-0}"\n',
|
||||
{ mode: 0o755 },
|
||||
);
|
||||
await writeFile(
|
||||
join(root, "s2s-client/.venv/bin/python"),
|
||||
'#!/bin/bash\nif [ "$1" = "-c" ]; then exit 0; fi\nexec node "$S2S_TEST_ROOT/child.mjs" backend "$@"\n',
|
||||
{ mode: 0o755 },
|
||||
);
|
||||
@@ -94,6 +99,7 @@ async function launcher(context: TestContext, env: Record<string, string> = {})
|
||||
cwd: tmpdir(),
|
||||
env: {
|
||||
...process.env,
|
||||
PATH: `${join(root, "bin")}:${process.env.PATH ?? ""}`,
|
||||
UI_PORT: String(publicPort),
|
||||
UI_HOST: "0.0.0.0",
|
||||
NODE_ENV: "production",
|
||||
@@ -138,6 +144,11 @@ for (const signal of ["SIGINT", "SIGTERM"] as const) {
|
||||
nodeEnv: "development",
|
||||
});
|
||||
assert.equal(run.output().includes("Installing"), false);
|
||||
assert.equal(
|
||||
await readFile(join(run.root, "uv-args"), "utf8"),
|
||||
`sync\n--project\n${run.root}/s2s-client\n--locked\n`,
|
||||
);
|
||||
assert.equal(await readFile(join(run.root, "uv-environment"), "utf8"), `${run.root}/s2s-client/.venv`);
|
||||
run.child.kill(signal);
|
||||
assert.equal(await run.exited, signal === "SIGINT" ? 130 : 143);
|
||||
for (const role of ["backend", "frontend"]) {
|
||||
@@ -168,6 +179,13 @@ await test("does not start Vite when the backend fails readiness", { timeout: 10
|
||||
assert.match(run.output(), /FastAPI exited before it was ready/);
|
||||
});
|
||||
|
||||
await test("does not start either server when uv sync fails", { timeout: 10_000 }, async (context) => {
|
||||
const run = await launcher(context, { S2S_TEST_UV_EXIT: "23" });
|
||||
assert.equal(await run.exited, 23, run.output());
|
||||
await assert.rejects(readFile(join(run.root, "backend.json")));
|
||||
await assert.rejects(readFile(join(run.root, "frontend.json")));
|
||||
});
|
||||
|
||||
await test("stops Vite if the backend exits after startup", { timeout: 10_000 }, async (context) => {
|
||||
const run = await launcher(context);
|
||||
await waitForFile(join(run.root, "frontend-worker-ready"));
|
||||
|
||||
Reference in New Issue
Block a user