Skip to content

ci: cache node_modules, Pods and compiled objects, and overlap the slow iOS steps - #7

Merged
andreialecu merged 4 commits into
mainfrom
ci/cache-builds
Nov 25, 2026
Merged

andreialecu merged 4 commits into
mainfrom
ci/cache-builds

Conversation

@andreialecu

@andreialecu andreialecu commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

The ios job took about 22 minutes with no caching at all. This caches what can be cached safely and builds less.

What changed

  • Dependencies (shared setup action, so the check job gets it too): .yarn/cache, .yarn/install-state.gz, node_modules and example/node_modules are restored, keyed on the OS, the architecture, .nvmrc, .yarnrc.yml, the Yarn release, .yarn/patches, yarn.lock and both package.json files. Only an exact key match is restored. Both the Yarn cache folder and node_modules are needed: without the cache folder Yarn downloads every package again even when node_modules is there. yarn install --immutable still runs.
  • Pods: example/ios/Pods is restored, keyed on the Podfile, Podfile.lock and yarn.lock. pod install still runs.
  • Compilation cache: Xcode's built-in compilation cache (COMPILATION_CACHE_ENABLE_CACHING=YES, with COMPILATION_CACHE_CAS_PATH outside the checkout) is kept between runs. The key has the Xcode build (the runner has Xcode 26.6, 17F113) and the lockfiles, and a partial match is restored, since entries are content addressed. The build step prints the number of hits and misses: 0 of 1045 cold, 1045 of 1045 warm. The cache is about 1 GB on disk and 380 MB compressed.
  • arm64 only: the generic simulator destination built every file for both arm64 and x86_64. The runner is Apple silicon, so ARCHS=arm64.
  • Metro: while Xcode builds, the job requests the exact bundle URL the debug app loads (taken from a real launch), so the first launch does not wait for bundling.
  • ffmpeg: Homebrew's downloads are restored, keyed on the runner image and the ffmpeg version, and the install runs with HOMEBREW_NO_AUTO_UPDATE, HOMEBREW_NO_INSTALL_CLEANUP and HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK.

Caches are saved right after the step that fills them, so a failing e2e run does not lose them.

Tried and dropped: booting the simulator in the background at the start of the job. On the runner it slowed the steps running beside it for minutes (setup-node went from about 5 s to 71-281 s), more than the boot takes, so the simulator is booted after the build as before.

When a cache misses or is stale

  • A miss only makes the run slower: it does the full install or build, then saves the cache.
  • node_modules, Pods and Homebrew downloads are restored only on an exact key match, and yarn install --immutable, pod install and brew install still run against them.
  • Compilation cache entries are keyed by a hash of every input of a compile: the source, the headers, the flags and the compiler. Anything that changed is a miss and is compiled again; a changed file is never replaced by a stale object. A different Xcode build uses a different cache key.

Timings (seconds)

Baseline: main run 45561584167. Cold: run 45598797065 (75891f2, empty caches, before the Homebrew change). Warm: run 45608262057 attempt 2 (9e32824, every cache restored).

ios step baseline cold warm
Setup (Node, yarn install) 217 394 25
ffmpeg (incl. cache steps) 32 72 27
Pods restore + pod install + save 80 202 37
Compilation cache restore + build + save 583 749 122
Prepare iOS simulator 82 166 162
Install and launch app 94 75 370
Run e2e tests 227 573 363
Job total 1335 2282 1149
check step baseline cold warm
Setup 103 211 17
Job total 130 256 65

The cold and warm runs landed on slow runners: the steps no cache touches (simulator, install and launch, e2e) took 2-4 times as long as in the baseline. Locally (Xcode 27.2), with a fresh derived data folder each time: 110 s without the cache, 136 s writing it, 51 s reading it.

e2e failures that are not from this change

Two e2e tests also fail on main (run 45585521876 on 2c808a3): "starts an AudioDecoder over after a flush (iOS)" and "handles the app going to the background". They fail here too. In some runs "exports WebGPU frames to an H.264 MP4 in memory" and "streams 210 frames at 1080x1920 to a file with a bounded backlog" time out (30 s eval timeout). They passed in other runs of this branch with the same build settings, and the first also timed out on PR #4 (run 45579218660).

Without its cache folder Yarn downloads every package again even when node_modules is there, so both are restored, on an exact key match only. yarn install --immutable still runs.
…le building

Xcode's compilation cache is kept between runs, keyed on the Xcode build and the lockfiles. The runner is Apple silicon, so x86_64 is no longer built. Metro is asked for the app's bundle while Xcode builds.
Keyed on the runner image and the ffmpeg version, with Homebrew's auto update, cleanup and dependents check off for the install.
ImageOS and ImageVersion are set on the runner, not in the workflow's env context, so read them in the shell.
@andreialecu
andreialecu merged commit 267905c into main Nov 25, 2026
1 of 2 checks passed
@andreialecu
andreialecu deleted the ci/cache-builds branch November 25, 2026 12:08
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.1.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant