The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Cloudflare from "@alchemy.run/cloudflare"; |
| 2 | import { expect } from "@alchemy.run/test"; |
| 3 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import { MinimumLogLevel } from "effect/References"; |
| 6 | import * as pathe from "pathe"; |
| 7 | import { expectUrlContains } from "../Utils/Http.ts"; |
| 8 | |
| 9 | const { test } = Test.make({ |
| 10 | providers: Cloudflare.providers(), |
| 11 | dev: true, |
| 12 | }); |
| 13 | |
| 14 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 15 | |
| 16 | const main = pathe.resolve(import.meta.dirname, "fixtures/python/worker.py"); |
| 17 | |
| 18 | // `dev: true` selects the local provider: the Python entry and its sibling |
| 19 | // modules are served by workerd (which embeds Pyodide) instead of being |
| 20 | // uploaded to Cloudflare. The first start may download the Pyodide runtime |
| 21 | // bundle, so the fetch retries generously. |
| 22 | test.provider( |
| 23 | "serves a Python Worker from local workerd", |
| 24 | (stack) => |
| 25 | Effect.gen(function* () { |
| 26 | yield* stack.destroy(); |
| 27 | |
| 28 | const worker = yield* stack.deploy( |
| 29 | Effect.gen(function* () { |
| 30 | return yield* Cloudflare.Worker("PythonLocalWorker", { |
| 31 | main, |
| 32 | env: { PY_SUFFIX: "local" }, |
| 33 | }); |
| 34 | }), |
| 35 | ); |
| 36 | |
| 37 | expect(worker.url).toBeDefined(); |
| 38 | yield* expectUrlContains(worker.url!, "alchemy-python-worker-7c1f suffix=local"); |
| 39 | |
| 40 | yield* stack.destroy(); |
| 41 | }).pipe(logLevel), |
| 42 | { |
| 43 | tags: ["provider:cloudflare", "provider:cloudflare:worker", "local"], |
| 44 | timeout: 240_000, |
| 45 | }, |
| 46 | ); |