Skip to content

Commit dfabb8f

Browse files
committed
ci: add compose test step
1 parent d9779b6 commit dfabb8f

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
branches: [ "master" ]
88

99
workflow_dispatch:
10+
inputs:
11+
run_compose_tests:
12+
description: 'Run Jetpack Compose UI Tests'
13+
required: false
14+
type: boolean
15+
default: false
1016

1117
jobs:
1218
build:
@@ -46,10 +52,38 @@ jobs:
4652
- name: Run tests
4753
run: ./gradlew testDebugUnitTest
4854

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
5077

5178
- name: Upload test report
5279
uses: actions/upload-artifact@v4
5380
with:
5481
name: unit_test_report
5582
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

Comments
 (0)