From 981915893aa7e34b1ba4bf6b77736c1a215a0b71 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sun, 2 Jan 2022 21:41:45 -0800 Subject: [PATCH] Added Android emulator snapshotting to improve start-up performance --- .github/workflows/android.yml | 37 ++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index b22a2af..3353f35 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -13,13 +13,13 @@ jobs: name: "Compile all sources" steps: - - name: checkout + - name: Checkout project uses: actions/checkout@v2 with: fetch-depth: 0 submodules: recursive - - name: set up JDK 11 + - name: Set up JDK 11 uses: actions/setup-java@v2 with: java-version: '11' @@ -50,13 +50,13 @@ jobs: runs-on: macos-latest steps: - - name: checkout + - name: Checkout project uses: actions/checkout@v2 with: fetch-depth: 0 submodules: recursive - - name: set up JDK 11 + - name: Set up JDK 11 uses: actions/setup-java@v2 with: java-version: '11' @@ -91,17 +91,17 @@ jobs: strategy: fail-fast: false matrix: - api-level: [ 15, 20, 24, 30 ] + api-level: [ 15, 21, 24, 31 ] target: [ default, google_apis ] steps: - - name: checkout + - name: Checkout project uses: actions/checkout@v2 with: fetch-depth: 0 submodules: recursive - - name: set up JDK 11 + - name: Set up JDK 11 uses: actions/setup-java@v2 with: java-version: '11' @@ -114,6 +114,26 @@ jobs: path: build key: build-${{ github.sha }} + - name: AVD cache + uses: actions/cache@v2 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ matrix.api-level }}-${{ matrix.target }} + + - 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 }} + target: ${{ matrix.target }} + 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." + - name: Run Instrumented Tests uses: reactivecircus/android-emulator-runner@v2 with: @@ -121,6 +141,9 @@ jobs: target: ${{ matrix.target }} arch: x86 profile: Nexus 6 + 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 connectedCheck --stacktrace - name: Save successful debug APK