| 1 | import * as AWS from "@/AWS"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { isolatedProject } from "../../../IsolatedProject.ts"; |
| 4 | |
| 5 | /** |
| 6 | * The isolated consumer project this job is bundled from (see |
| 7 | * `test/IsolatedProject.ts`): `main` lives outside the repository, so the |
| 8 | * bundle `cwd` resolves none of alchemy's dependencies and the bun |
| 9 | * bootstrap's own imports must be anchored by the bundler. |
| 10 | */ |
| 11 | export const project = isolatedProject("batch-job", import.meta.filename); |
| 12 | |
| 13 | /** Printed by the job body; asserted in the job's `/aws/batch/job` stream. */ |
| 14 | export const MARKER = "alchemy-batch-isolated-project-marker"; |
| 15 | |
| 16 | /** |
| 17 | * Minimal run-to-completion `AWS.Batch.JobDefinition` bundled from an |
| 18 | * isolated project. A `SUCCEEDED` job (container exit 0) proves the |
| 19 | * generated bootstrap booted — with its imports left external bun dies at |
| 20 | * module load and the job lands in `FAILED`. |
| 21 | */ |
| 22 | export default class IsolatedProjectJob extends AWS.Batch.JobDefinition<IsolatedProjectJob>()( |
| 23 | "BatchIsolatedProjectJob", |
| 24 | { |
| 25 | main: project.main, |
| 26 | jobDefinitionName: "alchemy-test-batch-isolated-project", |
| 27 | vcpus: 0.25, |
| 28 | memory: 512, |
| 29 | timeout: "10 minutes", |
| 30 | // Docker Hub's `oven/bun` image; the public.ecr.aws default mirror |
| 31 | // aggressively rate-limits anonymous pulls (429) during local builds. |
| 32 | docker: { base: "oven/bun:1" }, |
| 33 | }, |
| 34 | Effect.gen(function* () { |
| 35 | return { |
| 36 | run: Effect.gen(function* () { |
| 37 | // The awslogs driver captures stdout — print the marker for the |
| 38 | // out-of-band log assertion. |
| 39 | yield* Effect.sync(() => console.log(MARKER)); |
| 40 | }), |
| 41 | }; |
| 42 | }), |
| 43 | ) {} |