test.yml (2061B)
1 name: Test Build 2 3 on: 4 pull_request: 5 push: 6 branches: 7 - main 8 9 jobs: 10 test: 11 runs-on: ubuntu-latest 12 steps: 13 - uses: actions/checkout@v4 14 - uses: actions/setup-java@v4 15 with: 16 distribution: 'temurin' 17 java-version: '17' 18 - name: Setup Gradle 19 uses: gradle/actions/setup-gradle@v3 20 - name: Build and run unit tests 21 run: ./gradlew test 22 - name: Enable KVM group perms 23 run: | 24 echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules 25 sudo udevadm control --reload-rules 26 sudo udevadm trigger --name-match=kvm 27 - name: AVD cache 28 uses: actions/cache@v4 29 id: avd-cache 30 with: 31 path: | 32 ~/.android/avd/* 33 ~/.android/adb* 34 key: avd-36 35 - name: Create AVD and generate snapshot for caching 36 if: steps.avd-cache.outputs.cache-hit != 'true' 37 uses: reactivecircus/android-emulator-runner@v2 38 with: 39 api-level: 36 40 target: google_apis 41 arch: x86_64 42 force-avd-creation: false 43 emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none 44 disable-animations: false 45 script: echo "Generated AVD snapshot for caching." 46 - name: Build and run instrumented tests (UI & Accessibility) 47 uses: reactivecircus/android-emulator-runner@v2 48 with: 49 api-level: 36 50 target: google_apis 51 arch: x86_64 52 force-avd-creation: false 53 emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none 54 disable-animations: true 55 script: ./gradlew connectedAndroidTest 56 - name: Upload test reports 57 if: always() 58 uses: actions/upload-artifact@v4 59 with: 60 name: test-reports 61 path: | 62 app/build/reports/ 63 app/build/test-results/