@devries-cameron20 / t3code Mirror · read-only
Fork 0

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, 06:00 UTC

main
ts 73 lines 3.17 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as apprunner from "@distilled.cloud/aws/apprunner";
5 import * as Effect from "effect/Effect";
6 import * as HttpClient from "effect/http/HttpClient";
7 import * as Schedule from "effect/Schedule";
8 import { materializeIsolatedProject, removeIsolatedProject } from "../../IsolatedProject.ts";
9 import IsolatedProjectService, { project } from "./fixtures/isolated-project-service.ts";
10
11 // App Runner closed to new customers on 2026-04-30; accounts that weren't
12 // already customers get "Account <id> can't create new App Runner services".
13 // Set AWS_TEST_APPRUNNER_SERVICES=1 on an account that can still create them.
14 const appRunnerServices = !!process.env.AWS_TEST_APPRUNNER_SERVICES;
15
16 const { test } = Test.make({ providers: AWS.providers() });
17
18 // Live proof that the App Runner bun bootstrap boots when the service's
19 // `main` lives in an isolated project (see test/IsolatedProject.ts) — the
20 // bundle `cwd` resolves none of alchemy's dependencies, so the bootstrap's
21 // `@distilled.cloud/aws/*` / `@effect/platform-bun` imports must be bundled
22 // by the virtual-entry plugin rather than found from the project root. With
23 // them left external the container dies at module load, the health check
24 // never passes, and the service never reaches RUNNING.
25 //
26 // Heavy (Docker build + ECR push + 3-5 min App Runner provisioning, bills
27 // while running), so it is skipped under `--fast` like the platform e2e.
28 test.provider.skipIf(!!process.env.FAST || !appRunnerServices)(
29 "service bundled from an isolated project boots and serves HTTP",
30 (stack) =>
31 Effect.gen(function* () {
32 yield* materializeIsolatedProject(project);
33 yield* stack.destroy();
34
35 try {
36 const service = yield* stack.deploy(
37 Effect.gen(function* () {
38 return yield* IsolatedProjectService;
39 }),
40 );
41 expect(service.status).toBe("RUNNING");
42 expect(service.serviceUrl).toBeTruthy();
43
44 const health = yield* HttpClient.get(`https://${service.serviceUrl}/health`).pipe(
45 Effect.flatMap((res) =>
46 res.status === 200
47 ? res.json
48 : Effect.fail(new Error(`/health returned ${res.status}`)),
49 ),
50 Effect.retry({
51 schedule: Schedule.max([Schedule.fixed("3 seconds"), Schedule.recurs(20)]),
52 }),
53 );
54 expect(health).toEqual({ ok: true });
55
56 // Destroy immediately — App Runner services bill while running.
57 const { serviceArn } = service;
58 yield* stack.destroy();
59 const after = yield* apprunner.describeService({ ServiceArn: serviceArn }).pipe(
60 Effect.map((r) => (r.Service.Status ?? "UNKNOWN").toUpperCase()),
61 Effect.catchTag("ResourceNotFoundException", () => Effect.succeed("GONE" as const)),
62 );
63 expect(["GONE", "DELETED"]).toContain(after);
64 } finally {
65 yield* removeIsolatedProject(project);
66 }
67 }),
68 // Docker build + push (~2-4 min) + create (~3-5 min) + delete (~2-3 min).
69 {
70 tags: ["provider:aws", "provider:aws:apprunner", "live"],
71 timeout: 1_200_000,
72 },
73 );