Enable Integration tests in CI #121
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test | |
| on: | |
| push: | |
| branches: [ "**" ] | |
| pull_request: | |
| branches: [ "**" ] | |
| jobs: | |
| build-and-unit-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Gradle cache | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Decode Keystore | |
| env: | |
| ENCODED_KEYSTORE: ${{ secrets.ENCODED_KEYSTORE }} | |
| run: | | |
| echo $ENCODED_KEYSTORE | base64 -d > app/keystore.jks | |
| - name: Run Unit Tests | |
| run: ./gradlew test | |
| instrumentation-tests: | |
| needs: build-and-unit-tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| api-level: [ 29, 33, 36 ] | |
| image-target: [ google_apis ] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Enable KVM | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: AVD cache | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: avd-${{ matrix.api-level }}-{{ matrix.image-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.image-target }} | |
| arch: x86_64 | |
| 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 Instrumentation Tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ matrix.api-level }} | |
| target: ${{ matrix.image-target }} | |
| force-avd-creation: false | |
| emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| disable-animations: true | |
| arch: x86_64 | |
| script: ./gradlew connectedCheck | |
| - name: Collect logcat | |
| if: failure() | |
| run: | | |
| adb logcat -d > logcat.txt || true | |
| mkdir -p artifacts | |
| mv logcat.txt artifacts/ || true | |
| find app/build/reports -maxdepth 4 -type f -print0 | xargs -0 -I{} cp --parents {} artifacts/ || true | |
| find app/build/outputs/androidTest-results -maxdepth 6 -type f -print0 | xargs -0 -I{} cp --parents {} artifacts/ || true | |
| - name: Upload test artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-test-artifacts | |
| path: artifacts | |
| - name: Upload Test Reports | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-test-report | |
| path: '**/build/reports/' |