Skip to content

Using an AVD caching on Github Action #1819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/Build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,44 @@ jobs:
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}

# Take a snapshot if it doesn't have a cache.
- 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 }}
avd-name: test-${{ matrix.api-level }}
force-avd-creation: false
arch: x86_64
disk-size: 6000M
heap-size: 600M
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Build projects and run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
avd-name: test-${{ matrix.api-level }}
arch: x86_64
force-avd-creation: false
disable-animations: true
disk-size: 6000M
heap-size: 600M
script: ./gradlew connectedDemoDebugAndroidTest --daemon
# && killall -INT crashpad_handler || true
# came from https://github.com/ReactiveCircus/android-emulator-runner/issues/385#issuecomment-2492035091
script: |
/usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages -u | grep com.google.samples.apps.nowinandroid* | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall; ./gradlew connectedDemoDebugAndroidTest --daemon && killall -INT crashpad_handler || true

- name: Run local tests (including Roborazzi) for the combined coverage report (only API 30)
if: matrix.api-level == 30
Expand Down
Loading