From 2eedc6dc45f17884a9177bf6b304acf05766728e Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 28 Jan 2025 09:02:42 +0900 Subject: [PATCH 1/9] Add AVD cache feature. --- .github/workflows/Build.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index 5a212bffb..9dad459ce 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -191,11 +191,36 @@ 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 }} + + - 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 From c73861516eaffda99ce42e2fd7da68259f4431ee Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 28 Jan 2025 09:39:50 +0900 Subject: [PATCH 2/9] Add a comment. --- .github/workflows/Build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index 9dad459ce..8a049dda8 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -200,6 +200,7 @@ jobs: ~/.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 From b04c3dc7b2191f7c2bb6aaf72cacc289feda411b Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 28 Jan 2025 09:59:10 +0900 Subject: [PATCH 3/9] Uninstall apk before run test. --- .github/workflows/Build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index 8a049dda8..8975ee188 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -225,7 +225,8 @@ jobs: disable-animations: true disk-size: 6000M heap-size: 600M - script: ./gradlew connectedDemoDebugAndroidTest --daemon + script: | + /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm uninstall com.google.samples.apps.nowinandroid.demo.debug; ./gradlew connectedDemoDebugAndroidTest --daemon; - name: Run local tests (including Roborazzi) for the combined coverage report (only API 30) if: matrix.api-level == 30 From 4fc7db29d8ff7f71e662eacb2c0a4b44a4ed55c9 Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 28 Jan 2025 10:37:28 +0900 Subject: [PATCH 4/9] Catch all packages. --- .github/workflows/Build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index 8975ee188..e0b9706eb 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -226,7 +226,8 @@ jobs: disk-size: 6000M heap-size: 600M script: | - /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm uninstall com.google.samples.apps.nowinandroid.demo.debug; ./gradlew connectedDemoDebugAndroidTest --daemon; + /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages | grep com.google.samples.apps.nowinandroid.* | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall; ./gradlew connectedDemoDebugAndroidTest --daemon; + # /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm uninstall com.google.samples.apps.nowinandroid.demo.debug; - name: Run local tests (including Roborazzi) for the combined coverage report (only API 30) if: matrix.api-level == 30 From f4527379583f6e447361baf1c0a6979b261568f2 Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 28 Jan 2025 11:11:33 +0900 Subject: [PATCH 5/9] Update Build.yaml --- .github/workflows/Build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index e0b9706eb..e7eb74a55 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -226,7 +226,7 @@ jobs: disk-size: 6000M heap-size: 600M script: | - /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages | grep com.google.samples.apps.nowinandroid.* | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall; ./gradlew connectedDemoDebugAndroidTest --daemon; + /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages | grep com.google.samples.apps.nowinandroid* | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall; ./gradlew connectedDemoDebugAndroidTest --daemon; # /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm uninstall com.google.samples.apps.nowinandroid.demo.debug; - name: Run local tests (including Roborazzi) for the combined coverage report (only API 30) From 8407602638c8ba147ba4ae82d6ccf24723976cb4 Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 28 Jan 2025 11:45:45 +0900 Subject: [PATCH 6/9] Update Build.yaml --- .github/workflows/Build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index e7eb74a55..dab23fceb 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -213,7 +213,7 @@ jobs: 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." + script: echo "Generated AVD snapshot for caching."; /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages -f | grep com.google.samples.apps.nowinandroid* | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall; - name: Build projects and run instrumentation tests uses: reactivecircus/android-emulator-runner@v2 @@ -226,7 +226,7 @@ jobs: disk-size: 6000M heap-size: 600M script: | - /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages | grep com.google.samples.apps.nowinandroid* | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall; ./gradlew connectedDemoDebugAndroidTest --daemon; + /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages -f | grep com.google.samples.apps.nowinandroid* | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall; ./gradlew connectedDemoDebugAndroidTest --daemon; # /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm uninstall com.google.samples.apps.nowinandroid.demo.debug; - name: Run local tests (including Roborazzi) for the combined coverage report (only API 30) From 96991200c76d5ea0f90fd1fb7f1d6e39ae4a56b8 Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 28 Jan 2025 12:20:14 +0900 Subject: [PATCH 7/9] Update Build.yaml --- .github/workflows/Build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index dab23fceb..2e499a383 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -213,7 +213,7 @@ jobs: 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."; /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages -f | grep com.google.samples.apps.nowinandroid* | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall; + script: echo "Generated AVD snapshot for caching."; /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; - name: Build projects and run instrumentation tests uses: reactivecircus/android-emulator-runner@v2 @@ -226,7 +226,7 @@ jobs: disk-size: 6000M heap-size: 600M script: | - /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages -f | grep com.google.samples.apps.nowinandroid* | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall; ./gradlew connectedDemoDebugAndroidTest --daemon; + /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; # /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm uninstall com.google.samples.apps.nowinandroid.demo.debug; - name: Run local tests (including Roborazzi) for the combined coverage report (only API 30) From 5a19241d1066cbde6130661cdbea25f3f2acfb6b Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 28 Jan 2025 13:25:31 +0900 Subject: [PATCH 8/9] Fix an hang on problem. https://github.com/ReactiveCircus/android-emulator-runner/issues/385#issuecomment-2492035091 --- .github/workflows/Build.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index 2e499a383..99f9a2547 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -225,9 +225,10 @@ jobs: disable-animations: true disk-size: 6000M heap-size: 600M + # && 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; - # /usr/local/lib/android/sdk/platform-tools/adb -s emulator-5554 shell pm uninstall com.google.samples.apps.nowinandroid.demo.debug; + /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 From 93065c2a48d620043f97caa3d27c2662d2fd84a8 Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 28 Jan 2025 14:07:26 +0900 Subject: [PATCH 9/9] Remove unnecessary command. --- .github/workflows/Build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index 99f9a2547..0ca4d7536 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -213,7 +213,7 @@ jobs: 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."; /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; + script: echo "Generated AVD snapshot for caching." - name: Build projects and run instrumentation tests uses: reactivecircus/android-emulator-runner@v2