From 42c810195f4bf27b3dca532922ba5d739fad9e93 Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Tue, 5 Aug 2025 10:05:07 +0200 Subject: [PATCH 1/9] Cache Android Emulator generation As outline in https://github.com/marketplace/actions/android-emulator-runner#usage--examples we can cache the android emulator AVD generation. --- .github/workflows/agp-matrix.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/agp-matrix.yml b/.github/workflows/agp-matrix.yml index b4ddc7f7716..e4047826a9c 100644 --- a/.github/workflows/agp-matrix.yml +++ b/.github/workflows/agp-matrix.yml @@ -54,6 +54,25 @@ jobs: sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm + - 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@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2 + with: + api-level: 30 + 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." + # Clean, build and release a test apk - name: Make assembleUiTests run: make assembleUiTests @@ -62,7 +81,7 @@ jobs: - name: Run instrumentation tests uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2 with: - api-level: 30 + api-level: 30 force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true From 7c1e504f9424e1acfaf7237237f41661b2a85168 Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Tue, 5 Aug 2025 10:05:41 +0200 Subject: [PATCH 2/9] Fix whitespace --- .github/workflows/agp-matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/agp-matrix.yml b/.github/workflows/agp-matrix.yml index e4047826a9c..77e71c26c20 100644 --- a/.github/workflows/agp-matrix.yml +++ b/.github/workflows/agp-matrix.yml @@ -81,7 +81,7 @@ jobs: - name: Run instrumentation tests uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2 with: - api-level: 30 + api-level: 30 force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true From 2dca2fc18f3b1229559f3df2e4cf2c5c91f394b8 Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Tue, 5 Aug 2025 11:11:59 +0200 Subject: [PATCH 3/9] Update agp-matrix.yml --- .github/workflows/agp-matrix.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/agp-matrix.yml b/.github/workflows/agp-matrix.yml index 77e71c26c20..a7b376439dd 100644 --- a/.github/workflows/agp-matrix.yml +++ b/.github/workflows/agp-matrix.yml @@ -61,8 +61,7 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: avd-${{ matrix.api-level }} - + key: avd-api-30 - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2 @@ -70,7 +69,10 @@ jobs: api-level: 30 force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: false + disable-animations: true + disable-spellchecker: true + arch: arm64-v8a + disk-size: 4096M script: echo "Generated AVD snapshot for caching." # Clean, build and release a test apk @@ -86,9 +88,7 @@ jobs: emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true disable-spellchecker: true - target: 'aosp_atd' - arch: x86 - channel: canary # Necessary for ATDs + arch: arm64-v8a disk-size: 4096M script: ./gradlew sentry-android-integration-tests:sentry-uitest-android:connectedReleaseAndroidTest -DtestBuildType=release -Denvironment=github --daemon From 7cbebb785f05ab950a0fea769ba2abcf98103403 Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Tue, 5 Aug 2025 11:18:32 +0200 Subject: [PATCH 4/9] Update agp-matrix.yml --- .github/workflows/agp-matrix.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/agp-matrix.yml b/.github/workflows/agp-matrix.yml index a7b376439dd..dd1d9a28974 100644 --- a/.github/workflows/agp-matrix.yml +++ b/.github/workflows/agp-matrix.yml @@ -43,14 +43,9 @@ jobs: with: cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - - name: Setup KVM - shell: bash + - name: Enable KVM run: | - # check if virtualization is supported... - sudo apt install -y --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok - # allow access to KVM to run the emulator - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \ - | sudo tee /etc/udev/rules.d/99-kvm4all.rules + 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 @@ -62,6 +57,7 @@ jobs: ~/.android/avd/* ~/.android/adb* key: avd-api-30 + - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2 @@ -71,7 +67,7 @@ jobs: emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true disable-spellchecker: true - arch: arm64-v8a + arch: x86_64 disk-size: 4096M script: echo "Generated AVD snapshot for caching." @@ -88,7 +84,7 @@ jobs: emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true disable-spellchecker: true - arch: arm64-v8a + arch: x86_64 disk-size: 4096M script: ./gradlew sentry-android-integration-tests:sentry-uitest-android:connectedReleaseAndroidTest -DtestBuildType=release -Denvironment=github --daemon From d822e58435a2fa3d7088b5f1cfbe09d5e7b9a5c3 Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Tue, 5 Aug 2025 11:35:51 +0200 Subject: [PATCH 5/9] Improve Cache key --- .github/workflows/agp-matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/agp-matrix.yml b/.github/workflows/agp-matrix.yml index dd1d9a28974..ee486343d52 100644 --- a/.github/workflows/agp-matrix.yml +++ b/.github/workflows/agp-matrix.yml @@ -56,7 +56,7 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: avd-api-30 + key: avd-api-30-x86_64 - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' From 177088ee543050aae5ac0324ea4f41b266365d1c Mon Sep 17 00:00:00 2001 From: markushi Date: Wed, 6 Aug 2025 15:51:53 +0200 Subject: [PATCH 6/9] Add AVD caching to integration tests too --- .github/workflows/agp-matrix.yml | 8 +-- .../integration-tests-ui-critical.yml | 49 ++++++++++++------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.github/workflows/agp-matrix.yml b/.github/workflows/agp-matrix.yml index ee486343d52..a13253e9a04 100644 --- a/.github/workflows/agp-matrix.yml +++ b/.github/workflows/agp-matrix.yml @@ -56,18 +56,20 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: avd-api-30-x86_64 + key: avd-api-30-x86_64-aosp_atd - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2 with: api-level: 30 + target: aosp_atd + channel: canary # Necessary for ATDs + arch: x86_64 force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true disable-spellchecker: true - arch: x86_64 + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save disk-size: 4096M script: echo "Generated AVD snapshot for caching." diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 5e5f8030b99..3abf48db1fa 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -79,17 +79,36 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup KVM - shell: bash + - name: Enable KVM run: | - # check if virtualization is supported... - sudo apt install -y --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok - # allow access to KVM to run the emulator - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \ - | sudo tee /etc/udev/rules.d/99-kvm4all.rules + 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: AVD cache + uses: actions/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-api-${{ matrix.api-level }}-${{ matrix.api-arch }}-${{ matrix.target }} + + - name: Create AVD and generate snapshot for caching + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2 + with: + api-level: ${{ matrix.api-level }} + target: ${{ matrix.target }} + channel: ${{ matrix.channel }} + arch: ${{ matrix.arch }} + force-avd-creation: false + disable-animations: true + disable-spellchecker: true + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disk-size: 4096M + script: echo "Generated AVD snapshot for caching." + - name: Download APK artifact uses: actions/download-artifact@v4 with: @@ -104,21 +123,13 @@ jobs: uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2.34.0 with: api-level: ${{ matrix.api-level }} - force-avd-creation: false - disable-animations: true - disable-spellchecker: true target: ${{ matrix.target }} channel: ${{ matrix.channel }} arch: ${{ matrix.arch }} - emulator-options: > - -no-window - -no-snapshot-save - -gpu swiftshader_indirect - -noaudio - -no-boot-anim - -camera-back none - -camera-front none - -timezone US/Pacific + force-avd-creation: false + disable-animations: true + disable-spellchecker: true + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save script: | adb install -r -d "${{env.APK_NAME}}" maestro test "${{env.BASE_PATH}}/maestro" --debug-output "${{env.BASE_PATH}}/maestro-logs" From 415567942e54b2867a2ba7796351933a3b65fb63 Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Wed, 6 Aug 2025 15:56:44 +0200 Subject: [PATCH 7/9] Update integration-tests-ui-critical.yml --- .github/workflows/integration-tests-ui-critical.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests-ui-critical.yml b/.github/workflows/integration-tests-ui-critical.yml index 3abf48db1fa..785a9119570 100644 --- a/.github/workflows/integration-tests-ui-critical.yml +++ b/.github/workflows/integration-tests-ui-critical.yml @@ -92,7 +92,7 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: avd-api-${{ matrix.api-level }}-${{ matrix.api-arch }}-${{ matrix.target }} + key: avd-api-${{ matrix.api-level }}-${{ matrix.arch }}-${{ matrix.target }} - name: Create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' From 9293838a455d80a3465fa9245fcdb388444957a1 Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Wed, 6 Aug 2025 16:06:20 +0200 Subject: [PATCH 8/9] Fix missing target spec --- .github/workflows/agp-matrix.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/agp-matrix.yml b/.github/workflows/agp-matrix.yml index a13253e9a04..3980000c217 100644 --- a/.github/workflows/agp-matrix.yml +++ b/.github/workflows/agp-matrix.yml @@ -82,11 +82,13 @@ jobs: uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # pin@v2 with: api-level: 30 + target: aosp_atd + channel: canary # Necessary for ATDs + arch: x86_64 force-avd-creation: false - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true disable-spellchecker: true - arch: x86_64 + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disk-size: 4096M script: ./gradlew sentry-android-integration-tests:sentry-uitest-android:connectedReleaseAndroidTest -DtestBuildType=release -Denvironment=github --daemon From 32e0a23bfb1ce81343c62624238cd87841c2da7f Mon Sep 17 00:00:00 2001 From: Markus Hintersteiner Date: Wed, 6 Aug 2025 16:24:26 +0200 Subject: [PATCH 9/9] Update agp-matrix.yml --- .github/workflows/agp-matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/agp-matrix.yml b/.github/workflows/agp-matrix.yml index 3980000c217..42043992e36 100644 --- a/.github/workflows/agp-matrix.yml +++ b/.github/workflows/agp-matrix.yml @@ -69,7 +69,7 @@ jobs: force-avd-creation: false disable-animations: true disable-spellchecker: true - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot-save + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disk-size: 4096M script: echo "Generated AVD snapshot for caching."