diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index a4a49b8ee..f5d7ee3e7 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -213,15 +213,44 @@ jobs: build-scan-terms-of-use-url: "https://gradle.com/terms-of-service" build-scan-terms-of-use-agree: "yes" + - 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