Skip to content

ci: deploy-on-merge to Cloudflare + workspace-provision regression test - #261

Open
an1va wants to merge 2 commits into
mainfrom
fix/workspaces-r2-cd
Open

ci: deploy-on-merge to Cloudflare + workspace-provision regression test#261
an1va wants to merge 2 commits into
mainfrom
fix/workspaces-r2-cd

Conversation

@an1va

@an1va an1va commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Rebased on main after #262 (hosted tier: Workers + Hyperdrive + Postgres) merged. Scope narrowed to what's still additive on top of it.

1. CD — ship on merge (the main thing)

Adds a gated deploy job to ci.yml: runs the same pnpm run deploy a human runs, on push to main, only after every check job is green (PRs skip it via the if). This is what #262 didn't include — before this, nothing deploys on merge.

The merged deploy pipeline now also applies the Postgres schema (deploy:pg-schema), which silently no-ops without DATABASE_URL — so the job passes DATABASE_URL (plus CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID) to keep Neon in lockstep with the Worker. concurrency: deploy-production prevents overlapping deploys mid-migration.

Requires repo secrets: CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID (set), and DATABASE_URL (the Neon connection string — still needs setting).

2. Workspace-provision regression test

#262 shipped the deterministic personal-workspace id (ws_p_<userId>) that stops the duplicate "…'s Workspace" rows. This adds the missing guard: a test that fires 25 concurrent /v1/me and asserts exactly one workspace. Verified it fails on the old random-id behavior and passes on ws_p_ — so a future refactor back to a random id can't silently reintroduce the bug.

3. Cookie persistence (minor)

activeWorkspace now persists the resolved derive_ws cookie after provisioning, so subsequent requests short-circuit on the cookie instead of re-querying listWorkspaces every request until the user switches. Complements #262's deterministic id + Hyperdrive --caching-disabled.

Verification

  • Full suite green post-merge: typecheck (Node + worker), biome + guardrails, 607 api tests + core/db/storage/mcp/web/cli.
  • Live prod (Rob's 734834fc, Hyperdrive-bound) confirmed unaffected — my earlier D1 test deploys were superseded by his later pg deploy.

🤖 Generated with Claude Code

an1va and others added 2 commits July 2, 2026 12:35
…merge

Three fixes, all tracing back to the Dock->Derive move.

1. Duplicate "…'s Workspace" rows: provisionPersonal minted a random
   workspace id per call, so the parallel first-login request burst (no
   derive_ws cookie yet) each saw an empty listWorkspaces and each created
   a fresh workspace (~24 dupes observed). Use a deterministic id
   (ws_<userId>) so the existing upserts on workspace.id and (org_id,
   user_id) collapse the whole burst to one workspace + membership, with no
   lock. Also persist the resolved workspace cookie in activeWorkspace so
   later requests short-circuit the race. Regression test fires 25 parallel
   /v1/me and asserts exactly one workspace (fails on the old random id).

2. R2: point wrangler.toml at Derive's own D1 (the new Derive Cloudflare
   account) instead of the inherited id. The derive-blobs bucket the
   rebrand renamed to now exists and is bound on this account; existing
   blobs still need migrating from the old dock-blobs bucket separately.

3. CD: add a gated deploy job to ci.yml that runs the same pnpm run deploy
   on push to main, only after every check job is green. PRs skip it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reconcile the workspace-fix + CD branch with the merged hosted-tier work.

- wrangler.toml: take main's version — it already re-points at the Derive
  account and adds the required HYPERDRIVE binding (superseding my D1-id-only
  change).
- context.ts: #262 shipped the same deterministic personal-workspace id
  (ws_p_<userId>); keep it. My setWsCookie persistence in activeWorkspace and
  the concurrent-provision regression test ride on top. Test updated to the
  ws_p_ id.
- ci.yml deploy job: the merged `pnpm run deploy` now also applies the pg
  schema (deploy:pg-schema), which no-ops without DATABASE_URL. Add DATABASE_URL
  to the deploy env so CD keeps Neon in lockstep with the Worker.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@an1va an1va changed the title fix(workspaces): stop duplicate personal workspaces + wire deploy-on-merge ci: deploy-on-merge to Cloudflare + workspace-provision regression test Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant