diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 88ae10a8..20ecf39b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,31 +58,41 @@ jobs: sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm - # Modified AVD cache strategy + # Create and cache the AVD - name: AVD cache uses: actions/cache@v4 id: avd-cache with: path: | - ~/.android/avd/*/*.ini - ~/.android/avd/*/*.img - key: avd-${{ matrix.api-level }}-v1 # Added version suffix to invalidate old caches + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ matrix.api-level }}-v2 - # Always create a fresh AVD instance - - name: Create AVD - run: | - echo "no" | avdmanager create avd -n test -k "system-images;android-${{ matrix.api-level }};google_apis;x86_64" --force + # Create AVD and generate snapshot for caching + - name: Create AVD and generate snapshot + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + arch: x86_64 + target: google_apis + ram-size: 4096M + 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." + # Run the actual tests - name: Run instrumentation tests uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} - cores: 3 - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-snapshot - disable-animations: true - ram-size: 4096M - target: google_apis arch: x86_64 + target: google_apis + ram-size: 4096M + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true script: ./gradlew :samples:${{ matrix.sample }}:connectedDebugAndroidTest --no-daemon --stacktrace -PuseKsp=true - name: Publish test results