Skip to content

Latest commit

 

History

History
108 lines (106 loc) · 9.5 KB

release-and-deploy.md

File metadata and controls

108 lines (106 loc) · 9.5 KB

Release and deploy

How mate reaches users. Each step names the file that owns its detail.

  • CI. CI runs lint/format, typecheck, build and T1 on main, kh-bisect/** and pull requests (a newer push cancels older runs except on main). Other test suites and test machinery run only on a manual dispatch of CI or through a kh-bisect/** manifest naming them.
  • Landing. node scripts/land.ts lands the commit checked out when it starts on main. First, without the lock, it fetches, rebases onto origin/main, checks the sentence delta and that .mate-hq-ref is on mate-hq's main, numbers the branch's sentences and runs scripts/gate-changed.ts --full under nice: every refusal those steps give (conflict, sentences, pin, env, gate) comes without the lock. Then it queues for a lock shared by every worktree. Holding it, it fetches again: when origin/main has not moved it pushes the tree it gated; otherwise it rebases, repeats the checks and the numbering, and gates again with --passed <the commit its gate passed>, which runs the always-run stages and only the stages that read a file main's new commits changed (every stage when a gate selection input changed), then fast-forward pushes, printing LANDED <sha>. Nothing carries the first gate's verdict but that commit id inside the landing's own process. It needs MATE_HQ_CHECKOUT set to a mate-hq clone; a refusal (land: refused <class>: <reason>, non-zero exit) pushes nothing unless its reason says the push may have landed; a gate refusal names each red stage with its full log (gate red on <tip>: <stage> (<log path>)[; …], the gate's own last stderr line). The line before the last one is land: waited <s> s, held the lock <s> s. When a rebase, before the lock or under it, changes scripts/land.ts or a scripts/ module it imports, the landing lets go of the lock and its place in the queue and runs the rebased scripts/land.ts in its place, with the same arguments; that run's last line and exit code are the landing's. A waiting landing whose commits do not merge with the local origin/main is refused conflict while it waits. The command owns the queue, so a lane, a person and a script land alike and none adds its own lock or clock: it waits for the lock as long as another landing holds it (a holder that died releases it), and holding it has no time limit. SIGINT or SIGTERM, queued or landing, ends it as interrupted within 5 s, so a caller that stops it waits 5 s before SIGKILL. Once the push has started, origin decides: when its main contains the pushed tip, the landing prints LANDED <sha> whatever stopped it. A lock directory that names no holder (no landing makes one) is refused lock with its path, to be removed once no landing runs. The landing checks the branch's sentence diff and numbers its lane-local ids inside the rebased branch's last commit (amended, never a commit of its own, so a landing pushes only the branch's commits). The gate covers the numbered tip, and each <unit>: <old> → <new> is printed to stderr and added to that commit's body; a landing that does not land leaves its branch on its own rebased commit, before the numbering.
  • Hosted web client. A web-v* tag deploys https://mate.zerops.io through zerops.yml's prod setup. A successful CI run on main runs the release cutter for its commit automatically. For a minor release or a chosen green main commit, run Release hosted web on main in GitHub Actions or use node scripts/release-web.ts with --minor or --from-sha <sha> (--dry-run prints the plan). The script uses gh; set MATE_GH to a release-token wrapper if needed. It requires the same green CI verdict as the server release, skips a commit already included in a web tag, and prints nothing to release when no web build input changed. Configure the production web service's Zerops pipeline trigger to New Tag with regex ^web-v and setup prod. Keep main releasable; never break signing in with a Zerops account.
  • Staging web. zerops.yml's staging setup builds a test target's web (alfa, the standing test environments env-N) against that target's HQ, named by the web service's variable MATE_HQ_URL (VITE_HQ_ORIGIN); Mates born from it pin T3CODE_ZEROPS_HQ_ORIGIN to that HQ. It runs at its service's zeropsSubdomain; the build refuses a service without either. Deploy it from a checkout with zcli push -P <project id> -S <web id> --setup staging. From a linked worktree add --workspace-state clean (zcli's default state writes a temporary index into .git, which is a file there); it pushes HEAD.
  • Dev environments' web. zerops.yml's dev setup serves https://mate.<host> of each dev environment, one service per environment, named after it. Deploy a branch with the manual Deploy dev Mate workflow (.github/workflows/deploy-dev.yml).
  • Design harness. Every apps/web/design*.html page over its fixtures, listed at /design/ and in the kit at /kit as its flows: the dev server always serves it, and prod, staging, dev and a Mate's preview build it beside the app (VITE_DESIGN_HARNESS=beside). It reads no account and calls no server. The harness setup builds it alone, in place of the app (VITE_DESIGN_HARNESS=alone): a static place to look at states with no account and no Mate. Deploy that from a checkout with zcli push -P <project id> -S <service id> --setup harness; nothing deploys it by itself.
  • Hosted client's service worker. prod and staging build with VITE_APP_SHELL_WORKER: app-shell: /sw.js answers every load with the origin's page, so the first load after a deploy runs it, and keeps that page with its files behind it; the kept page answers only when the origin cannot (offline, an error status). To retire it, set the variable to retire and deploy: /sw.js becomes a worker that clears its caches and unregisters on each browser's next navigation. Keep that deploy up; deleting the variable or /sw.js leaves installed workers in place.
  • Shared production HQ. Deployment is owned by the private zeropsio/mate-hq repository.
  • Mate server release. node scripts/release-mate.ts (--minor when the client's compatibility floor rises, --dry-run prints the plan). It calls GitHub through gh; set MATE_GH to use a wrapper that holds the release token instead. zcp installs the latest stable release in containers by itself. A main commit may be released once its newest ci.yml run on main has completed with every required job green (checkJobIds in scripts/ci-blame.ts, the checks Release Smoke's verdict demands); a red informative job (tests, smokes, mobile) does not hold it. A missing run, a run still in progress and a required job not green are each refused with their own words. The release workflow asks the same verdict (node scripts/ci-blame.ts --release-verdict), and the lockfile policy check is part of Check. A source that changed no server artifact input since the last release (the sources the published artifact's sourcemaps name, plus the build tooling in scripts/lib/server-artifact-inputs.ts) cuts no release: the script prints nothing to release and exits 0; version-only edits never count. --from-sha <sha> --would-release prints release if the source needs a tag or already has one, and no-release if no server artifact input changed. It cuts, tags and pushes nothing. A v* tag on origin at the source or its version bump prevents tagging that source again. A release run waits for that tag's successful publication and checksum verification, including a tag another clone pushed. A superseded tag uses its own manifest. Only the newest tag is eligible for a workflow rerun. A run that may cut a release holds <git common dir>/mate-release.lock until it ends; a second run from the same clone or one of its worktrees prints another release holds <path>; nothing cut and exits 1. Between clones or machines the tag push decides which tag is verified.
  • Install check against a staged release. Before promoting a release, run zcp's live seam case on an e2e container that has Mate enabled (make e2e-deploy in zeropsio/zcp, ZCP_HOST names the service): ZCP_E2E_MATE_RELEASE=https://github.com/zeropsio/mate/releases/download/v<version>/stable.json /var/www/e2e-test -test.run TestMateInstall_Release_Serves -test.v -test.timeout 600s. It installs that release through download → SHA-256 → install and waits for mate serve to be ready. Red means the release does not install or its serve rejects the launch argv or environment: do not promote it. The release stays installed on that container either way.
  • Unreleased server build in a running container. eval/scripts/mate-dev-push.sh {zcp|mate|all} in a zeropsio/zcp checkout; MATE_REPO names this checkout when it is not at the script's default. It needs the project VPN and an explicit EVAL_REMOTE_HOST. It is not a release: without a dev pin a dev Mate build stays only until a release newer than its base is known. zcp mate pin --for <duration> --reason <text> keeps every dev build in the container (24 h by default, at most 7 days, the reason is required); zcp mate pin --end removes it and zcp mate pin shows it. A container restart replaces a dev zcp with the latest release whatever the pin says, but the pin, kept across the restart, still covers a dev Mate; a redeploy loses the bundles and the pin (zeropsio/zcp:docs/spec-mate.md §2.1a, §2.6).