Skip to content

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.

WhatPath (typical)Key by
Package manager storehandled 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/emulatorimage ID
AVD and boot snapshot~/.android/avd (homogeneous runners only)image ID, emulator version, toets version
WebDriverAgent build~/Library/Caches/toets/tvos-wdatoets version, Xcode version
App buildyour build outputhash 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/emulator and 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.