From 6bb298454f6a5ad80c3a02a2ea90f6f36eb11038 Mon Sep 17 00:00:00 2001 From: Shawn Kang Date: Sun, 3 Aug 2025 00:54:47 +0900 Subject: [PATCH 1/5] test: add Android instrumented test on CI script --- .github/workflows/CI.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8252371..f84b3fa 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -27,10 +27,17 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Run unit test, lint check and build - run: ./gradlew test lintDebug assembleDebug + - name: Setup Android emulator + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 33 + script: | + echo "Emulator started!" + + - name: Run tests, lint check and build + run: ./gradlew test connectedAndroidTest lintDebug assembleDebug - - name: Upload Lint Report Artifact + - name: Upload lint report artifact if: always() uses: actions/upload-artifact@v4 with: From cbee0c5f2426fb2cbbc14591614ed9482fc3bdac Mon Sep 17 00:00:00 2001 From: Shawn Kang Date: Sun, 3 Aug 2025 01:12:37 +0900 Subject: [PATCH 2/5] fix: prevent Android emulator from terminating before tests --- .github/workflows/CI.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f84b3fa..5b94f95 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -27,15 +27,24 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Setup Android emulator + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666"' | sudo tee /etc/udev/rules.d/99-kvm.rules + sudo udevadm control --reload-rules + sudo udevadm trigger + + - name: Run unit tests and lint check + run: ./gradlew --no-daemon --stacktrace --continue test lintDebug + + - name: Run instrumented tests on emulator uses: reactivecircus/android-emulator-runner@v2 with: api-level: 33 - script: | - echo "Emulator started!" + arch: x86_64 + script: ./gradlew --no-daemon --stacktrace --continue connectedAndroidTest - - name: Run tests, lint check and build - run: ./gradlew test connectedAndroidTest lintDebug assembleDebug + - name: Assemble debug build + run: ./gradlew --no-daemon --stacktrace assembleDebug - name: Upload lint report artifact if: always() From 6614787f5d0a7448a52ed878a930f7f7d4373adb Mon Sep 17 00:00:00 2001 From: Shawn Kang Date: Sun, 3 Aug 2025 01:38:32 +0900 Subject: [PATCH 3/5] refactor: enable caching to speed up emulator boot --- .github/workflows/CI.yml | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5b94f95..fa7554a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,12 +17,8 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: "21" - distribution: "temurin" - cache: "gradle" + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 - name: Grant execute permission for gradlew run: chmod +x gradlew @@ -33,18 +29,37 @@ jobs: sudo udevadm control --reload-rules sudo udevadm trigger - - name: Run unit tests and lint check - run: ./gradlew --no-daemon --stacktrace --continue test lintDebug + - name: AVD cache + uses: actions/cache@v4 + id: avd-cache # Specify a unique GitHub Actions ID for the cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-33 + + - 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: 33 + arch: x86_64 + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim + disable-animations: false + script: echo "Generated AVD snapshot for caching." - - name: Run instrumented tests on emulator + - name: Run instrumented tests from snapshot uses: reactivecircus/android-emulator-runner@v2 with: api-level: 33 arch: x86_64 + force-avd-creation: false + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim script: ./gradlew --no-daemon --stacktrace --continue connectedAndroidTest - - name: Assemble debug build - run: ./gradlew --no-daemon --stacktrace assembleDebug + - name: Run unit tests, lint check and build + run: ./gradlew --no-daemon --stacktrace --continue test lintDebug assembleDebug - name: Upload lint report artifact if: always() From e13dd11a19068189c99983764c2eec989f08e1d2 Mon Sep 17 00:00:00 2001 From: Shawn Kang Date: Sun, 3 Aug 2025 01:52:31 +0900 Subject: [PATCH 4/5] fix: specify JDK version --- .github/workflows/CI.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index fa7554a..5694b10 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,6 +19,8 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 + with: + java-version: "21" - name: Grant execute permission for gradlew run: chmod +x gradlew From d49bcbe5014c50e85ee755e07c072e90eb497349 Mon Sep 17 00:00:00 2001 From: Shawn Kang Date: Sun, 3 Aug 2025 02:00:23 +0900 Subject: [PATCH 5/5] fix: revert Java version specification step --- .github/workflows/CI.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5694b10..e938d85 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,10 +17,14 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 + - name: Setup Java + uses: actions/setup-java@v4 with: - java-version: "21" + java-version: '21' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Grant execute permission for gradlew run: chmod +x gradlew