Caching
Device-backed runs spend most of their setup time downloading and booting. Cache what is slow and deterministic, and key each cache by exactly the inputs that change it.
| What | Path (typical) | Key by |
|---|---|---|
| Package manager store | handled by actions/setup-node cache: | lockfile hash |
| Playwright browsers | ~/.cache/ms-playwright (Linux), ~/Library/Caches/ms-playwright (macOS) | Playwright version |
| Android system image | $ANDROID_HOME/system-images, $ANDROID_HOME/emulator | image ID |
| AVD and boot snapshot | ~/.android/avd (homogeneous runners only) | image ID, emulator version, toets version |
| WebDriverAgent build | ~/Library/Caches/toets/tvos-wda | toets version, Xcode version |
| App build | your build output | hash of the app's sources |
yaml
# Only cache ~/.android/avd when every runner has the same host CPU (e.g. self-hosted).
# On heterogeneous cloud runners, cache $ANDROID_HOME/emulator and the system image instead.
- uses: actions/cache@v4
with:
path: ~/.android/avd
key: avd-${{ runner.os }}-${{ env.ANDROID_TV_IMAGE }}-${{ env.CACHE_EPOCH }}-${{ hashFiles('package-lock.json') }}Traps
- Snapshots are not portable across CPUs. An AVD snapshot taken on one host CPU or emulator version can fail or hang on boot on another VM. On heterogeneous cloud runners (such as GitHub-hosted Ubuntu runners), cache
$ANDROID_HOME/emulatorand the system image, not~/.android/avd. Only cache AVD snapshots on homogeneous self-hosted runners, and include the emulator version in the key. - Do not cache app data or test results. Each run must start from a clean device state; toets resets devices for that reason.
- Restore keys can hide breakage. A partial match may restore a cache built for another image or Xcode. Prefer exact keys for device caches.