Skip to content

Build AVD cache

Build AVD cache #211

name: Build AVD cache
on:
schedule:
- cron: '0 10 * * *'
workflow_dispatch:
inputs:
JDK_VERSION:
description: The JDK version to use
type: number
default: 11
env:
JDK_VERSION: ${{ inputs.JDK_VERSION || '11' }}
jobs:
avd-cache-update:
# > It is now recommended to use the Ubuntu (ubuntu-latest) runners which
# > are 2-3 times faster than the macOS ones which are also a lot more expensive.
# https://github.com/ReactiveCircus/android-emulator-runner#running-hardware-accelerated-emulators-on-linux-runners
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [26, 29, 30]
steps:
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Set up JDK ${{ env.JDK_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JDK_VERSION }}
distribution: temurin
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: google_apis
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."