|
| 1 | +name: UI Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + ui-tests: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + steps: |
| 11 | + - name: Checkout the code |
| 12 | + uses: actions/checkout@v4 |
| 13 | + |
| 14 | + - name: Set up JDK 17 |
| 15 | + uses: actions/setup-java@v4 |
| 16 | + with: |
| 17 | + java-version: '17' |
| 18 | + distribution: 'adopt' |
| 19 | + |
| 20 | + - name: Cache gradle |
| 21 | + uses: actions/cache@v4 |
| 22 | + with: |
| 23 | + path: | |
| 24 | + ~/.gradle/caches |
| 25 | + ~/.gradle/wrapper |
| 26 | + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 27 | + restore-keys: | |
| 28 | + gradle-${{ runner.os }}- |
| 29 | +
|
| 30 | + - name: Decode google-services.json |
| 31 | + run: echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 -d > app/google-services.json |
| 32 | + env: |
| 33 | + GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }} |
| 34 | + |
| 35 | + - name: Make gradlew executable |
| 36 | + run: chmod +x gradlew |
| 37 | + |
| 38 | + - name: Build for debug with gradle |
| 39 | + run: ./gradlew assembleDebug |
| 40 | + |
| 41 | + - name: Start Android Emulator for Compose Tests |
| 42 | + run: | |
| 43 | + docker run -d --name nexus \ |
| 44 | + -p 4723:4723 -p 6080:6080 \ |
| 45 | + --privileged \ |
| 46 | + budtmo/docker-android-x86-7.1.1:1.8-p2 |
| 47 | +
|
| 48 | + # Wait for the emulator to be fully started |
| 49 | + echo "Waiting for emulator to start..." |
| 50 | + sleep 60 |
| 51 | +
|
| 52 | + # Check if emulator is running |
| 53 | + docker exec nexus adb devices |
| 54 | +
|
| 55 | + - name: Run Jetpack Compose UI Tests |
| 56 | + run: ./gradlew connectedAndroidTest |
| 57 | + |
| 58 | + - name: Stop Android Emulator |
| 59 | + if: always() |
| 60 | + run: docker stop nexus && docker rm nexus |
| 61 | + |
| 62 | + - name: Upload UI test report |
| 63 | + if: always() |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: compose_test_report |
| 67 | + path: app/build/reports/androidTests/ |
0 commit comments