ci(ios): batch scheduled TestFlight uploads by commit count and age
Adds configurable batching to scheduled iOS uploads. The checkout prerequisite #13703 has merged; this PR is based on current main.
Problem
Both iOS upload workflows poll main: CMUX INTERNAL every 20 minutes, official cmux.app every hour. Their decide jobs skip only when main is unchanged, when no iOS path changed (INTERNAL), or, since #13660, when the last attempt failed and no iOS path changed since then. On a busy day (~100 merges) nearly every poll finds something, so INTERNAL uploads about every 20 minutes and official about every hour. Each upload is a cold Release archive on a Blacksmith macOS runner, and PR CI uses the same pool, where queues already run 30–60 minutes.
Rule
A scheduled poll that the existing rules would already upload now also has to pass a batching check. It uploads when
at least one relevant commit is pending since the last successful upload AND (pending relevant commits ≥ N OR the oldest pending relevant commit is ≥ T minutes old)
workflow_dispatchalways uploads, as today.- The twice-daily DEMO lane is not batched.
- Every existing skip rule is unchanged. The check runs only when those rules have already chosen to upload against a known prior upload. The first upload, with no prior upload, is not batched.
- The polls stay as they are. No push trigger is added.
- The step summary gets the reason, for example
skipped: 2/5 iOS commits, oldest 45/180 minorupload: 1/5 iOS commits, oldest 181/180 min (age reached).
"Commits" means main's first-parent commits, one per merged PR, each diffed against its first parent. A commit's age is its committer date, which is when the PR landed on main.
Defaults and tuning
| Lane | N (repo var, default) | T (repo var, default) |
|---|---|---|
| CMUX INTERNAL | IOS_TESTFLIGHT_INTERNAL_MIN_COMMITS = 5 | IOS_TESTFLIGHT_INTERNAL_MAX_AGE_MINUTES = 180 |
| official cmux.app | IOS_APPSTORE_MIN_COMMITS = 10 | IOS_APPSTORE_MAX_AGE_MINUTES = 360 |
Set them under Settings → Secrets and variables → Actions → Variables. If a variable is unset or empty, the in-workflow default applies. An invalid value logs a warning and falls back to the default, so a typo can't stop uploads. Zero disables only that threshold: MIN_COMMITS=0 uses age alone, and MAX_AGE_MINUTES=0 uses count alone. Set both to zero to disable batching and upload any pending change. MIN_COMMITS=1 also uploads any pending relevant commit.
What counts as relevant
- INTERNAL reuses the workflow's own
iosRelevantPathsarray. The script reads that array fromios-testflight.ymlitself, so the list still lives in one place, with the same prefix/exact matching. - Official has no path filter today (it skips only unchanged revisions), so every main commit counts. Adding an iOS path filter to that lane would be a separate change.
How it works
scripts/ci/ios_upload_batch_decision.pyholds the rule (puredecide()plus the git reader).- The decide job adds two steps that run only when needed:
- a sparse, blobless, depth-1 checkout of the script, the notes-history fetcher, and (INTERNAL) the workflow file;
ios/scripts/fetch-testflight-notes-history.sh <last upload>(from #13703), which deepens to the base, followed by the script.
- The job output becomes
steps.batch.outputs.X || steps.decide.outputs.X, so every other path keeps the decide script's answer. - REST cost:
- INTERNAL: no new REST calls. History comes from git.
- Official: one new call,
actions/artifacts?name=cmux-app-testflight-upload, which gives the SHA of the last completed upload.
- Anything the script can't read (for example, a base that isn't an ancestor) fails open to an upload, the same way the existing compare step does.
- One necessary change to the official "unchanged" check. A poll that batching skips still concludes successfully. If "last successful run == HEAD" alone meant "already shipped", a quiet main would never reach the age threshold. The skip now requires the last successful run and the last completed upload marker to both be HEAD. The assignment-retry path is untouched.
Expected upload counts
Simulated on real main first-parent history, 2026-09-08 → 09-22, with polls at the real cron offsets. The old column models only the "any relevant change" rule.
| Day | Merges | iOS merges | INTERNAL before → after | Official before → after |
|---|---|---|---|---|
| Busy (09-22) | 122 | 20 | 13 → 4 | 16 → 8 |
| Busy (09-21) | 95 | 13 | 12 → 4 | 20 → 6 |
| Busy (09-20) | 105 | 8 | 7 → 3 | 20 → 7 |
| Quiet (09-19) | 13 | 1 | 1 → 1 | 8 → 3 |
| Quiet (09-08) | 7 | 4 | 3 → 1 | 4 → 0 (carried over) |
| 15 days total | 110 → 48 | 197 → 59 |
Every relevant change still ships: at the latest one poll after T (≤ 3 h 20 min for INTERNAL, ≤ 7 h for official), and sooner once N pile up.
Tests
- New:
tests/test_ios_upload_batching.py, 20 tests.- Rule cases: below both thresholds → skip; count reached → upload; age reached with 1 commit → upload; zero commits → skip regardless of age; dispatch → upload; unset vars → defaults; invalid vars → defaults with a warning.
- The git reader against a real repo with a
--no-ffmerge: first-parent counting and merge diffs. - Fail-open on an unreachable base.
- The workflow wiring.
- The path list read from the workflow matches the notes generator's contract.
- Registered in
ci-guards.yml(release-ios) and inPATH_OWNERSinscripts/ci/workflow_guard_groups.py. - Passing locally:
- every
tests/test_ios_*.py tests/test_ci_linux_guard_routing.py,tests/test_ci_release_guard_structure.py,tests/test_ci_guard_workflow_structure.pyactionlint -config-file .github/actionlint.yaml
- every
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Batches the scheduled iOS TestFlight uploads (CMUX INTERNAL every 20 min, cmux.app hourly) by pending commit count and age, and shrinks their macOS checkout to free up the shared runner pool.
Batching rule
- A scheduled poll uploads only when the existing rules would AND (≥ N pending relevant commits OR the oldest is ≥ T minutes old). Defaults are 5/180 min (INTERNAL) and 10/360 min (official), configurable via repo variables; unset or invalid values fall back to the defaults.
- Manual dispatch and the DEMO lane are unchanged. The official unchanged-skip now also requires the last completed upload marker to be HEAD, because a batch-skipped poll still concludes successfully.
- The count uses main's first-parent commits from a sparse, blobless, history-deepened checkout: no new REST calls for INTERNAL, one for official. If the base is reachable only through a merge's second parent, the script fails open to an upload.
- Reuses the workflow's own path filter for INTERNAL relevance; the official lane has none, so every main commit counts.
- The batch steps run under a 5-minute timeout and continue on error, so any failure there falls back to the decide script's answer instead of stopping scheduled uploads.
Lean macOS checkout
- Upload checkouts are now fetch-depth 1 with no submodules or tags; the prebuilt GhosttyKit downloads first, and zig plus the from-source build run only when it's unavailable.
- INTERNAL's notes range is fetched after checkout by a new script that deepens only to the previous beta commit; history that can't be fetched falls back to the generic notes line without failing the upload.
Summary by CodeRabbit
-
New Features
- Scheduled iOS TestFlight and App Store uploads are now grouped by relevant commit count or waiting time, reducing unnecessary uploads.
- Manual uploads continue to run immediately.
- TestFlight release notes can be generated from shallow checkouts when history is available.
-
Bug Fixes
- Upload workflows now fall back safely when release history or prebuilt components are unavailable.
-
Performance
- iOS upload workflows use leaner checkouts and prefer prebuilt components to reduce build time.