|
7 | 7 | branches: [ "master" ] |
8 | 8 |
|
9 | 9 | workflow_dispatch: |
| 10 | + inputs: |
| 11 | + run_compose_tests: |
| 12 | + description: 'Run Jetpack Compose UI Tests' |
| 13 | + required: false |
| 14 | + type: boolean |
| 15 | + default: false |
10 | 16 |
|
11 | 17 | jobs: |
12 | 18 | build: |
@@ -46,10 +52,38 @@ jobs: |
46 | 52 | - name: Run tests |
47 | 53 | run: ./gradlew testDebugUnitTest |
48 | 54 |
|
49 | | - # TODO ADD COMPOSE TESTS STEP |
| 55 | + - name: Start Android Emulator for Compose Tests |
| 56 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_compose_tests }} |
| 57 | + run: | |
| 58 | + docker run -d --name nexus \ |
| 59 | + -p 4723:4723 -p 6080:6080 \ |
| 60 | + --privileged \ |
| 61 | + budtmo/docker-android-x86-7.1.1:1.8-p2 |
| 62 | +
|
| 63 | + # Wait for the emulator to be fully started |
| 64 | + echo "Waiting for emulator to start..." |
| 65 | + sleep 60 |
| 66 | +
|
| 67 | + # Check if emulator is running |
| 68 | + docker exec nexus adb devices |
| 69 | +
|
| 70 | + - name: Run Jetpack Compose UI Tests |
| 71 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_compose_tests }} |
| 72 | + run: ./gradlew connectedAndroidTest |
| 73 | + |
| 74 | + - name: Stop Android Emulator |
| 75 | + if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.run_compose_tests }} |
| 76 | + run: docker stop nexus && docker rm nexus |
50 | 77 |
|
51 | 78 | - name: Upload test report |
52 | 79 | uses: actions/upload-artifact@v4 |
53 | 80 | with: |
54 | 81 | name: unit_test_report |
55 | 82 | path: app/build/reports/tests/testDebugUnitTest/ |
| 83 | + |
| 84 | + - name: Upload UI test report |
| 85 | + if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.run_compose_tests }} |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: compose_test_report |
| 89 | + path: app/build/reports/androidTests/ |
0 commit comments