|
| 1 | +name: UI Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + ui-tests: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout the code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Set up JDK 17 |
| 18 | + uses: actions/setup-java@v4 |
| 19 | + with: |
| 20 | + java-version: '17' |
| 21 | + distribution: 'adopt' |
| 22 | + |
| 23 | + - name: Cache gradle |
| 24 | + uses: actions/cache@v4 |
| 25 | + with: |
| 26 | + path: | |
| 27 | + ~/.gradle/caches |
| 28 | + ~/.gradle/wrapper |
| 29 | + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 30 | + restore-keys: | |
| 31 | + gradle-${{ runner.os }}- |
| 32 | +
|
| 33 | + - name: Decode google-services.json |
| 34 | + run: echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 -d > app/google-services.json |
| 35 | + env: |
| 36 | + GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }} |
| 37 | + |
| 38 | + - name: Make gradlew executable |
| 39 | + run: chmod +x gradlew |
| 40 | + |
| 41 | + - name: Build for debug with gradle |
| 42 | + run: | |
| 43 | + ./gradlew assembleDebug assembleAndroidTest |
| 44 | + ls -la app/build/outputs/apk/debug/ |
| 45 | + ls -la app/build/outputs/apk/androidTest/debug/ |
| 46 | +
|
| 47 | + - name: Enable KVM |
| 48 | + run: | |
| 49 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 50 | + sudo udevadm control --reload-rules |
| 51 | + sudo udevadm trigger --name-match=kvm |
| 52 | +
|
| 53 | + - name: AVD cache |
| 54 | + uses: actions/cache@v4 |
| 55 | + id: avd-cache |
| 56 | + with: |
| 57 | + path: | |
| 58 | + ~/.android/avd/* |
| 59 | + ~/.android/adb* |
| 60 | + key: avd-30-x86_64 |
| 61 | + |
| 62 | + - name: Create AVD and generate snapshot for caching |
| 63 | + if: steps.avd-cache.outputs.cache-hit != 'true' |
| 64 | + uses: reactivecircus/android-emulator-runner@v2 |
| 65 | + with: |
| 66 | + api-level: 30 |
| 67 | + arch: x86_64 |
| 68 | + profile: pixel_4 |
| 69 | + force-avd-creation: false |
| 70 | + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 71 | + disable-animations: false |
| 72 | + script: echo "Generated AVD snapshot for caching." |
| 73 | + |
| 74 | + - name: Run UI tests on Android Emulator |
| 75 | + uses: reactivecircus/android-emulator-runner@v2 |
| 76 | + with: |
| 77 | + api-level: 30 |
| 78 | + arch: x86_64 |
| 79 | + profile: pixel_4 |
| 80 | + force-avd-creation: false |
| 81 | + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 82 | + disable-animations: true |
| 83 | + script: | |
| 84 | + # Wait for emulator to be fully ready |
| 85 | + adb wait-for-device |
| 86 | + echo "Waiting for boot to complete..." |
| 87 | + adb shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done' |
| 88 | + sleep 10 |
| 89 | +
|
| 90 | + # Verify emulator ABI matches app |
| 91 | + echo "Emulator ABI:" |
| 92 | + adb shell getprop ro.product.cpu.abi |
| 93 | +
|
| 94 | + # Install and run tests |
| 95 | + ./gradlew installDebug |
| 96 | + ./gradlew connectedDebugAndroidTest |
| 97 | +
|
| 98 | + - name: Upload UI test report |
| 99 | + if: always() |
| 100 | + uses: actions/upload-artifact@v4 |
| 101 | + with: |
| 102 | + name: compose_test_report |
| 103 | + path: | |
| 104 | + app/build/reports/androidTests/connected/**/* |
| 105 | + app/build/outputs/androidTest-results/connected/**/* |
| 106 | + if-no-files-found: warn |
0 commit comments