diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8252371..e938d85 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,20 +17,57 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up JDK 21 + - name: Setup Java uses: actions/setup-java@v4 with: - java-version: "21" - distribution: "temurin" - cache: "gradle" + java-version: '21' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Run unit test, lint check and build - run: ./gradlew test lintDebug assembleDebug + - 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: 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 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: Run unit tests, lint check and build + run: ./gradlew --no-daemon --stacktrace --continue test lintDebug assembleDebug - - name: Upload Lint Report Artifact + - name: Upload lint report artifact if: always() uses: actions/upload-artifact@v4 with: