The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as HttpClient from "effect/http/HttpClient"; |
| 5 | import * as Schedule from "effect/Schedule"; |
| 6 | import { materializeIsolatedProject, removeIsolatedProject } from "../../IsolatedProject.ts"; |
| 7 | import IsolatedProjectInstance, { project } from "./fixtures/isolated-project-instance.ts"; |
| 8 | import { assertInstanceTerminated } from "./Gone.ts"; |
| 9 | import * as Test from "./VpcTest.ts"; |
| 10 | |
| 11 | const { test } = Test.make({ providers: AWS.providers() }); |
| 12 | |
| 13 | // Live proof that the EC2 hosted-program bootstrap boots when `main` lives |
| 14 | // in an isolated project (see test/IsolatedProject.ts) — the bundle `cwd` |
| 15 | // resolves none of alchemy's dependencies, so the bootstrap's |
| 16 | // `@distilled.cloud/aws/*` / `@effect/platform-bun` imports must be bundled |
| 17 | // by the virtual-entry plugin rather than found from the project root. With |
| 18 | // them left external bun dies at module load under systemd and the app port |
| 19 | // never answers. |
| 20 | // |
| 21 | // Heavy (instance boot + bun install + S3 sync + systemd, ~2 min), so |
| 22 | // skipped under --fast alongside the other isolated-project e2e tests. |
| 23 | test.provider.skipIf(!!process.env.FAST)( |
| 24 | "instance program bundled from an isolated project serves HTTP", |
| 25 | (stack) => |
| 26 | Effect.gen(function* () { |
| 27 | yield* materializeIsolatedProject(project); |
| 28 | yield* stack.destroy(); |
| 29 | |
| 30 | try { |
| 31 | const { instanceId, url } = yield* stack.deploy( |
| 32 | Effect.gen(function* () { |
| 33 | const instance = yield* IsolatedProjectInstance; |
| 34 | return { |
| 35 | instanceId: instance.instanceId, |
| 36 | url: instance.url, |
| 37 | }; |
| 38 | }), |
| 39 | ); |
| 40 | expect(url).toBeTruthy(); |
| 41 | |
| 42 | // Poll until the instance boots, installs bun, syncs the bundle from |
| 43 | // S3, and the systemd unit serves 200 on :3000. Connection errors |
| 44 | // before the server binds are normalised to "not ready". |
| 45 | const base = url!; |
| 46 | const served = yield* HttpClient.get(`${base}/health`).pipe( |
| 47 | Effect.map((res) => res.status === 200), |
| 48 | Effect.catch(() => Effect.succeed(false)), |
| 49 | Effect.repeat({ |
| 50 | schedule: Schedule.spaced("8 seconds"), |
| 51 | until: (ok) => ok, |
| 52 | times: 75, |
| 53 | }), |
| 54 | ); |
| 55 | expect(served).toBe(true); |
| 56 | |
| 57 | yield* stack.destroy(); |
| 58 | yield* assertInstanceTerminated(instanceId); |
| 59 | } finally { |
| 60 | yield* removeIsolatedProject(project); |
| 61 | } |
| 62 | }), |
| 63 | { tags: ["provider:aws", "provider:aws:ec2", "live"], timeout: 1_200_000 }, |
| 64 | ); |