Skip to content

ci: cut CI wall time and macOS minutes - #752

Merged
gre merged 5 commits into
masterfrom
ci/optimize
Oct 29, 2026
Merged

gre merged 5 commits into
masterfrom
ci/optimize

Conversation

@gre

@gre gre commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Measured on a fully green run (#745, run 40719911613): the critical path was lint → Build iOS App (28 min + 28 min queued) → Detox (42 min), about 1h45, with 5 macOS jobs per run. GitHub Free allows 5 concurrent macOS jobs for the whole account, so a single PR saturated it and several PRs queued for up to 90 min. The repo's Actions cache was at 10.3 GB of its 10 GB quota, so caches were constantly evicted.

iOS: one job, one build

ios replaces build-ios, build-ios-new-arch, lint-podspec and test-detox-ios:

Before After
Detox recompiled the app (22 min) after build-ios compiled it (19 min) One build-for-testing shared by XCTest (test-without-building) and Detox
XCTest rebuilt for its simulator (6.9 min) No rebuild
Generic destination compiled arm64 and x86_64 ARCHS=arm64 (the runners are Apple Silicon)
build-ios-new-arch compiled the same thing (RN ≥ 0.82 is new-arch only) Removed
Simulator booted and the app reinstalled for each test file (4 min 42 s, then ~40 s per file) Simulator booted at job start; app installed once; detox test --reuse
Metro started after the build Metro bundles during the build (2 workers)

The Detox simulator is now pinned: iPhone 16 Pro on iOS 26.2 (IOS_SIMULATOR_OS). That's the runtime Detox had been choosing on its own, the newest on the image, and the one the references were made on. It's newer than Xcode 16.4's SDK, so the build uses a generic arm64 destination and XCTest runs on the newest runtime that isn't newer than the SDK. If the image drops 26.2, the job says so clearly; build, XCTest and the podspec lint still report.

Steps after the build don't depend on each other's success: a failing XCTest doesn't hide Detox, and the podspec lint runs last.

Caches

  • Gradle and NuGet (~3 GB) are saved from master only (actions/cache/save) and only restored on PRs. Per-PR copies were evicting master's: Windows got "Cache not found" and then spent 5 min re-saving 3 GB on every run.
  • master runs are no longer cancelled by a newer push (cancel-in-progress only for PRs), so they finish writing the caches.
  • The CocoaPods cache keyed on the gitignored Podfile.lock (always macOS-pods-) is removed.

Paths

A changes job (dorny/paths-filter@v4) skips the platforms a PR doesn't touch (iOS, Android, Windows, web). For example, an Android-only PR no longer pays ~87 min of macOS. Pushes to master run everything. No required checks are configured, so skipped jobs block nothing.

Android

  • One ABI (arm64-v8a) instead of the four in gradle.properties: Skia/Reanimated/worklets were compiled 4×. arm64 keeps the APK artifact installable on phones and Apple Silicon emulators.
  • The JUnit run keeps -PnewArchEnabled=false, so the paper spec (RN 0.80/0.81) stays compiled.
  • build-apk.yml (release, all ABIs) runs on master, on demand, and on PRs touching Android, the example or the library.

Misc

npm ci everywhere. The library is no longer built twice per job (prepare already builds it on npm ci). The Playwright server wait polls instead of sleep 30. The first Detox file's beforeAll gets 300 s (the first launch exceeded 180 s on #744/#746/#749).

Trade-offs

  • With --reuse, app data persists between test files (they used to start from a fresh install). The tests compare captures, not app state.
  • The debug APK artifact is arm64 only.
  • This PR touches ci.yml, so it runs every job. The gain will show on later PRs.

Measured on this PR (run on e16c5a5)

Job Before (#745) This PR
iOS build + XCTest + Detox Build iOS App 28.5 min then Detox 41.9 min (≈70 min sequential, + queue) 38.4 min, a single job
— app build 19 min + 22 min (rebuilt by Detox) 14.8 min, once
— Detox tests 15.5 min 9.8 min
— XCTest 6.9 min (rebuild) 5.4 min (after Detox, no rebuild)
Android 20.6 min 9.5 min
Windows 25 min 16.3 min
SwiftPM 4.6 min 3.3 min
macOS jobs per run 5 2

ccache dropped: all 464 compiles went through RN's ccache-clang.sh, but ccache recorded no call and stored nothing (whether with CCACHE_DIR or its default directory). Likely an Xcode quirk in how it passes the environment to the compilers. To investigate separately.

The first run of the merged job also exposed an XCTest wait of 29 min, cold-booting a second simulator alongside Detox's. XCTest now runs after Detox, once Metro and the simulator are shut down: 5.4 min.

Validation

actionlint + shellcheck pass, except warnings already on master in the web summary step. Four /code-review passes, findings fixed. Actual timings: in this PR's CI.

🤖 Generated with Claude Code

gre and others added 4 commits October 28, 2026 22:39
The critical path was lint -> Build iOS App (28 min + queue) -> Detox
(42 min + queue), about 1h45, with 5 macOS jobs per run against the
account's 5 concurrent macOS jobs.

iOS:
- One `ios` job replaces build-ios, build-ios-new-arch, lint-podspec and
  test-detox-ios. It builds once (build-for-testing, arm64 only: the
  generic destination compiled x86_64 too) and runs XCTest
  (test-without-building, which no longer rebuilds) and Detox on that
  build; Detox used to rebuild the app for 22 min. The new-arch job built
  the same thing (RN >= 0.82 has no old architecture).
- ccache (USE_CCACHE, read by react_native_post_install), cached per
  example lockfile.
- The Detox simulator (iPhone 16 Pro on iOS 26.2, pinned: the references
  come from it, not from Xcode 16.4's 18.x SDK) boots at job start, the
  app is installed once and `detox test --reuse` stops the per-file
  reinstall (~40 s each); Metro bundles during the build.
- Steps after the build run independently, so one failure doesn't hide
  the other results; the podspec lint runs last.

Caches: Gradle, NuGet (~3 GB) and ccache are written from master only
and restored on PRs. Per-PR copies were evicting master's from the 10 GB
quota (10.3 GB used), so Windows saved 3 GB on every run (5 min) and
nothing hit. Master runs are no longer cancelled by a newer push.

Paths: a `changes` job (dorny/paths-filter) skips the platforms a pull
request doesn't touch; pushes to master run everything.

Android: one ABI (arm64-v8a) instead of the four in gradle.properties;
the JUnit run keeps -PnewArchEnabled=false for the paper spec.

Misc: npm ci everywhere, no second library build (`prepare` already
builds it), the Playwright server wait polls instead of sleeping 30 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ci.yml covers a debug build on every Android-touching PR; the release
build (all ABIs) now runs on master, on demand and on PRs touching
Android, the example or the library. It restores ci.yml's Gradle cache
read-only and uses npm ci.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the first run of the merged job:
- ccache stayed empty (0.0 GB) although the build went through RN's
  ccache-clang.sh: Xcode doesn't pass CCACHE_DIR to the compiler, so
  ccache wrote to ~/Library/Caches/ccache. Cache that directory, and trim
  it to 2 GB before saving (CCACHE_MAXSIZE isn't passed through either).
- XCTest spent 29 min before its first test, cold-booting an iOS 18.x
  simulator next to the booted Detox one and Metro. It now runs after
  Detox, once Metro and the Detox simulator are shut down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every compile went through RN's ccache-clang.sh (464 of 464), yet ccache
recorded no call and stored nothing in either directory tried, so it only
added install and cache steps. Left for a separate investigation (likely
how Xcode passes the environment to compiler tasks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The prefetch asked for index.bundle?platform=ios&dev=true&minify=false,
but RCTBundleURLProvider requests lazy=true plus Fusebox's
excludeSource/sourcePaths and app=<bundle id>. Metro then built a second
bundle on the first app launch with its 2 workers, and the home screen
missed the 120 s wait (the first-launch flake on #744/#746/#748/#749 and
this PR's runs). Match the query, and give that first wait 240 s within
the 300 s hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gre
gre marked this pull request as ready for review October 29, 2026 01:20
Copilot AI balanced review requested due to automatic review settings October 29, 2026 01:20
@gre
gre merged commit a596c34 into master Oct 29, 2026
15 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants