Repository navigation
feat(deploy): defer a shared target that brings migrations to a reviewer, expand the schema there, and alias a proved target - #274
Merged
Conversation
…wer, expand the schema there, and alias a proved target The script half of wiring release candidates as targets (#195 stage E, ADR-0111). A shared target uses production's database, and ADR-0111 decided that one bringing a new migration waits for a reviewer. scripts/deploy-target.sh now knows when that is, and does the migration only where it may. New step 2b, before anything is created: - It reads what production runs: wrangler's deployments and versions of the production Worker, through .github/scripts/active-version.py, the same reading deploy-worker.sh uses. A target is a Preview OF production, so production must be deployed (exit 1 otherwise). - It classifies the candidate against production's live commit, with .github/scripts/classify-deploy.sh, fetching that commit by its sha when no branch holds it, as deploy-worker.sh does. A live state it cannot read (split, unknown) counts as bringing migrations. - Migrations, without ALLOW_MIGRATE=true: `deferred=true`, exit 0, nothing done. That is the cue for the job whose environment has reviewers and the database route. - Migrations, with ALLOW_MIGRATE=true: scripts/migrate-ci.sh --no-contract runs before the Preview. A contract migration stays production's deploy's alone. It sees only the database's secrets (DATABASE_URL and the tunnel's service token), and nothing else sees them. - No migrations: no migration, even with ALLOW_MIGRATE. New step 9: TARGET_ALIAS (one of the policy's aliases, checked before anything is asked) points that alias at the target with flagship.py alias, LAST, after the smoke and its control. A release candidate becomes `staging` only once proved. An alias that does not stick fails the deploy, and the target is removed like any other failure. Outputs: deferred and migrations_changed join the others. Tests (test-deploy-target.sh, under dash: 161 passed, 40 new). The fakes now answer `deployments list` and `versions list` for production (one tagged version, none, split, a listing that fails), and add a classifier and a migration that record their arguments and the secrets they saw. Cases: - the classifier asked with (production's commit, the candidate); - no migration when there is none, even with ALLOW_MIGRATE; - a candidate with migrations deferred, with no Preview, no migration and nothing left; - a split production deferred without asking the classifier; - with ALLOW_MIGRATE: `--no-contract`, before the Preview, the database's secrets seen by the migration only, and the target right afterwards; - an undeployed production, a failed listing, a failed classifier and a failed migration, each failing before any Preview; - the alias set last, naming the target; an alias that does not stick removing the target; - the new usage errors. 14 hand mutants of the new code each fail it. Not here: the workflow that runs it (deploy.yml's switch, its two jobs and environments), which comes next. Refs: #195 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
The script half of deploying release candidates as targets (#195 stage E, ADR-0111). It changes
scripts/deploy-target.shonly; no workflow runs it yet. The workflow half is the next PR, stacked on this one.
Why
A shared target uses production's database. ADR-0111 decided that a shared target bringing a new migration waits for a
reviewer, and that contract migrations happen only in production's deploy. The script now knows when a candidate brings a
migration, and migrates only where it is allowed to.
What changes in
deploy-target.shNew step 2b, before anything is created:
active-version.py,the same reading
deploy-worker.shuses. A target is a Preview of production, so production must be deployed.classify-deploy.sh, fetching that commit by its shaif needed, as
deploy-worker.shdoes. A live state it can't read (split or unknown) counts as bringing migrations.ALLOW_MIGRATEALLOW_MIGRATE=truedeferred=true, exit 0, nothing done: the cue for the reviewer-gated jobmigrate-ci.sh --no-contractfirst, seeing only the database's secrets, then the deployNew step 9:
TARGET_ALIASpoints an alias of the policy, such asstaging, at the target. It's set last, after thesmoke and its control, so a candidate becomes
stagingonly once proved. An alias that doesn't stick fails the deploy andremoves the target. An alias the policy lacks is refused before anything is asked.
New outputs:
deferredandmigrations_changed.Tests
test-deploy-target.sh, under dash: 161 checks pass, 40 of them new.deployments listandversions listfor production: one tagged version, none, split,or a listing that fails;
ALLOW_MIGRATE, the migration runs with--no-contract, before the Preview, and is the only step that sees thedatabase's secrets;
Hand mutants: 14 versions of the new code with a planted bug; each one fails the tests.
Also passing: every
depsstep, everyci-scriptstest (40, each on its own under dash), and actionlint.Refs #195
🤖 Generated with Claude Code