feat(environments): daily environment builds (SUPER-3017)
Draft
SA
16d ago+189+189+012345678901234567890123456789-0-0-0123456789
Milestone 2 of plans/20261030-0017-environment-builds.md (#9104). Stacked on #9110.
What it does
POST /api/environments/jobs/daily-builds, verified as a QStash request, runsqueueDailyBuilds()under a Sentry cron monitor (environment-daily-builds).- For every environment that is not archived, it starts a
dailybuild through the samestartEnvironmentBuildthe button and CLI use. It skips:- organizations on the free plan (checked once per organization);
- environments whose last three finished builds all failed (plan decision D6). A successful manual build ends the pause;
- anything
startEnvironmentBuildrefuses: no[install], already running, no repositories. Counted by reason.
- No change check: an unchanged environment is built too (design doc, about $0.05 per environment per day).
- Returns
{ queued, skipped: { reason: count }, failed }.
Needs doing by hand after merge: create the QStash schedule in the Upstash console, daily at 09:00 UTC (0 9 * * *, to match the Sentry monitor), POSTing to https://<api>/api/environments/jobs/daily-builds. Like reconcile-usage, the schedule is not in this repo.
Verified
- Unit tests with injected dependencies: paid built and free skipped; paused after three failures; a refusal counted by reason without stopping the loop.
packages/trpcandapps/apitypecheck; Biome clean.
Not verified: a real scheduled run. That needs the Upstash schedule, which only exists after merge.
Linear: SUPER-3017
Summary by cubic
Adds a QStash-scheduled job that starts a build of every environment that can have one — non-archived, on a paid plan, with [install], and not paused — including unchanged environments.
POST /api/environments/jobs/daily-buildsverifies the QStash signature, then runsqueueDailyBuilds()under a Sentry cron monitor.- The job skips free organizations (checked once per org), environments whose last three finished builds all failed — a successful manual build ends the pause — and anything
startEnvironmentBuildrefuses, counting each refusal by reason. - Returns
{ queued, skipped: { reason: count }, failed }. - After merge, create the QStash schedule in the Upstash console at
0 9 * * *posting to/api/environments/jobs/daily-builds; the schedule lives outside this repo, likereconcile-usage.