From 87fff7beccdddb8a8e3626959b814fdda0960fa1 Mon Sep 17 00:00:00 2001 From: Charles Dyas Date: Fri, 31 Jul 2026 13:27:55 -0400 Subject: [PATCH] ci: pin the deployed Worker config and test against the real runtime Commits the custom domain routes and workers_dev fallback that the cutover added, so the deployed configuration lives in git rather than only on Cloudflare. Adds a second CI job that runs the e2e suite against workerd instead of the Vite dev server, and fails the build if wrangler reports a missing Node builtin. Both bugs that surfaced during the migration were invisible to the existing job: the nodejs_compat flag throws at runtime rather than at build, and a prerendered feed served the wrong content type. The old suite passed green through both. The nodejs_compat guard is verified by removing the flag and confirming the job fails, so it is not a check that can only pass. --- .github/workflows/quality.yml | 35 +++++++++++++++++++++++++++++++++++ README.md | 2 +- wrangler.jsonc | 20 ++++++++++++++------ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 4e79cfe..6af2b56 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -25,3 +25,38 @@ jobs: - run: npm run build - run: npx playwright install --with-deps chromium - run: npm run test:e2e + + # The suite above runs against the Vite dev server, which cannot see problems + # that only exist on the Workers runtime. Two such bugs shipped green during + # the migration: a missing nodejs_compat flag that throws at runtime rather + # than at build, and a prerendered feed served with the wrong content type. + # This job runs the same tests against workerd. + workers-runtime: + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version-file: .nvmrc + cache: npm + - run: npm ci + - run: npm run build + - run: npx playwright install --with-deps chromium + - name: Start workerd + run: npx wrangler dev --port 8788 --local &> /tmp/wrangler.log & + - name: Wait for it to serve + run: | + for i in $(seq 1 40); do + curl -sf -o /dev/null http://localhost:8788/ && exit 0 + sleep 3 + done + echo "workerd never became ready"; cat /tmp/wrangler.log; exit 1 + - name: Fail on runtime compatibility warnings + run: | + if grep -qiE "wasn't found on the file system but is built into node" /tmp/wrangler.log; then + echo "Worker is missing a nodejs_compat import:"; grep -iE -A3 "built into node" /tmp/wrangler.log + exit 1 + fi + - run: E2E_BASE_URL=http://localhost:8788 npm run test:e2e diff --git a/README.md b/README.md index 5753abc..9ff6e3d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The local server runs at [localhost:3000](http://localhost:3000). | Command | Purpose | | ------------------ | ------------------------------------------- | | `npm run dev` | Start the local server | -| `npm run build` | Create the Cloudflare Workers build | +| `npm run build` | Create the Cloudflare Workers build | | `npm run preview` | Preview a production build | | `npm run check` | Run formatting, lint, types, and unit tests | | `npm run test:e2e` | Run the Playwright browser suite | diff --git a/wrangler.jsonc b/wrangler.jsonc index 434e433..d73e263 100644 --- a/wrangler.jsonc +++ b/wrangler.jsonc @@ -6,12 +6,20 @@ // Worker throws at runtime rather than at build time. "compatibility_flags": ["nodejs_compat"], "main": ".svelte-kit/cloudflare/_worker.js", + // Keep the workers.dev hostname alive as a fallback that does not depend on + // the zone's DNS being correct. + "workers_dev": true, + // Custom domains; Cloudflare manages the DNS records for these itself. + "routes": [ + { "pattern": "cjdyas.design", "custom_domain": true }, + { "pattern": "www.cjdyas.design", "custom_domain": true }, + ], "assets": { "directory": ".svelte-kit/cloudflare", - "binding": "ASSETS" + "binding": "ASSETS", }, "observability": { - "enabled": true + "enabled": true, }, // Contact form abuse guard. The in-memory limiter this replaces kept its // counter inside a single isolate, which does not survive on Workers. @@ -23,8 +31,8 @@ "namespace_id": "1001", "simple": { "limit": 5, - "period": 60 - } - } - ] + "period": 60, + }, + }, + ], }