ci: deploy-on-merge to Cloudflare + workspace-provision regression test - #261
Open
an1va wants to merge 2 commits into
Open
ci: deploy-on-merge to Cloudflare + workspace-provision regression test#261an1va wants to merge 2 commits into
an1va wants to merge 2 commits into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased on
mainafter #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
deployjob toci.yml: runs the samepnpm run deploya human runs, on push tomain, only after every check job is green (PRs skip it via theif). 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 withoutDATABASE_URL— so the job passesDATABASE_URL(plusCLOUDFLARE_API_TOKEN/CLOUDFLARE_ACCOUNT_ID) to keep Neon in lockstep with the Worker.concurrency: deploy-productionprevents overlapping deploys mid-migration.Requires repo secrets:
CLOUDFLARE_API_TOKEN+CLOUDFLARE_ACCOUNT_ID(set), andDATABASE_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/meand asserts exactly one workspace. Verified it fails on the old random-id behavior and passes onws_p_— so a future refactor back to a random id can't silently reintroduce the bug.3. Cookie persistence (minor)
activeWorkspacenow persists the resolvedderive_wscookie after provisioning, so subsequent requests short-circuit on the cookie instead of re-queryinglistWorkspacesevery request until the user switches. Complements #262's deterministic id + Hyperdrive--caching-disabled.Verification
734834fc, Hyperdrive-bound) confirmed unaffected — my earlier D1 test deploys were superseded by his later pg deploy.🤖 Generated with Claude Code