Skip to content

Commit 41e00dc

Browse files
committed
ci: create a ui test workflow
1 parent dfabb8f commit 41e00dc

File tree

2 files changed

+67
-36
lines changed

2 files changed

+67
-36
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ 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
1610

1711
jobs:
1812
build:
@@ -52,38 +46,8 @@ jobs:
5246
- name: Run tests
5347
run: ./gradlew testDebugUnitTest
5448

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
77-
7849
- name: Upload test report
7950
uses: actions/upload-artifact@v4
8051
with:
8152
name: unit_test_report
8253
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/

.github/workflows/ui-tests.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

Comments
 (0)