1import * as GCP from "@/GCP";
2import * as Test from "@/Test/Alchemy";
3import { expect } from "alchemy-test";
4import * as Effect from "effect/Effect";
5import { cloneFixture } from "../../Cloudflare/Utils/Fixture.ts";
6import { expectUrlContains } from "../../Cloudflare/Utils/Http.ts";
7import { dockerAvailable } from "../bindingHost.ts";
8import {
9 assertSiteGone,
10 awsFixture,
11 cloudRunUrl,
12 liveOptions,
13 logLevel,
14 serviceIdentity,
15 tempRoot,
16} from "./site.ts";
17
18const { test } = Test.make({ providers: GCP.providers() });
19
20const fixtureDir = awsFixture("octane-app");
21const fixtureEntries = [
22 ".gitignore",
23 "package.json",
24 "octane.config.ts",
25 "vite.config.ts",
26 "index.html",
27 "src",
28 "public",
29];
30
31test.provider.skipIf(!dockerAvailable)(
32 "Octane: deploy, GET page and API route, destroy, gone",
33 (stack) =>
34 Effect.gen(function* () {
35 yield* stack.destroy();
36
37 const rootDir = yield* cloneFixture(fixtureDir, {
38 prefix: "alchemy-octane-gcp-",
39 tempRoot,
40 entries: fixtureEntries,
41 });
42
43 const deployed = yield* stack.deploy(
44 Effect.gen(function* () {
45 const site = yield* GCP.Website.Octane("Web", {
46 rootDir,
47 memo: {
48 include: [
49 "src/**",
50 "public/**",
51 "package.json",
52 "octane.config.ts",
53 "vite.config.ts",
54 "index.html",
55 ],
56 },
57 });
58 return { site };
59 }),
60 );
61
62 const url = deployed.site.url as string;
63 expect(url).toMatch(cloudRunUrl);
64 expect(deployed.site.service).toBeDefined();
65 const service = serviceIdentity(deployed.site.service!);
66
67 yield* expectUrlContains(`${url}/`, "OCTANE_AWS_PAGE_MARKER", {
68 timeout: "180 seconds",
69 label: "Octane /",
70 });
71 yield* expectUrlContains(
72 `${url}/api/hello?echo=roundtrip`,
73 "OCTANE_AWS_API_MARKER",
74 {
75 timeout: "30 seconds",
76 label: "Octane /api/hello?echo=roundtrip",
77 },
78 );
79
80 yield* stack.destroy();
81 yield* assertSiteGone(service);
82 }).pipe(logLevel),
83 liveOptions(900_000),
84);