Skip to content

Commit f53c8aa

Browse files
committed
ci: replace docker with android emulator runner action
1 parent 546f7d4 commit f53c8aa

File tree

1 file changed

+34
-79
lines changed

1 file changed

+34
-79
lines changed

.github/workflows/ui-tests.yml

Lines changed: 34 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -42,88 +42,43 @@ jobs:
4242
- name: Build for debug with gradle
4343
run: ./gradlew assembleDebug assembleAndroidTest
4444

45-
- name: Check Docker version
45+
- name: Enable KVM
4646
run: |
47-
docker --version
48-
docker ps
47+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
48+
sudo udevadm control --reload-rules
49+
sudo udevadm trigger --name-match=kvm
4950
50-
- name: Start Docker Android Container
51-
run: |
52-
# Pull the Android emulator image
53-
docker pull budtmo/docker-android:emulator_13.0_v2.16.2-p0
54-
55-
# Run the container with environment variables for faster boot
56-
docker run -d --name android-container \
57-
-p 4723:4723 -p 6080:6080 -p 5554:5554 -p 5555:5555 \
58-
-e EMULATOR_ARGS="-no-snapshot-save -no-audio -no-boot-anim -no-window -gpu swiftshader_indirect -accel on" \
59-
--privileged \
60-
budtmo/docker-android:emulator_13.0_v2.16.2-p0
61-
62-
# Wait for container to fully initialize
63-
echo "Waiting for Android container to initialize..."
64-
sleep 120 # Increased from 90 to 120 seconds
65-
66-
# Check container status
67-
docker ps
68-
docker logs android-container --tail 50
69-
70-
- name: Install Android tools
71-
run: |
72-
sudo apt-get update
73-
sudo apt-get install -y android-tools-adb
74-
adb version
75-
76-
- name: Set up ADB and connect to device
77-
run: |
78-
adb start-server
79-
80-
# Get container IP
81-
CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' android-container)
82-
echo "Container IP: $CONTAINER_IP"
83-
84-
# Connect to the emulator
85-
adb connect $CONTAINER_IP:5555
86-
87-
# Wait for device to be fully booted (increased time)
88-
echo "Waiting for device to fully boot..."
89-
adb wait-for-device
90-
sleep 30
91-
92-
# Check boot completion
93-
while true; do
94-
boot_completed=$(adb shell getprop sys.boot_completed | tr -d '\r')
95-
if [ "$boot_completed" == "1" ]; then
96-
break
97-
fi
98-
echo "Waiting for boot to complete..."
99-
sleep 10
100-
done
101-
102-
# Check connected devices
103-
adb devices -l
104-
105-
# Disable animations
106-
adb shell settings put global window_animation_scale 0.0
107-
adb shell settings put global transition_animation_scale 0.0
108-
adb shell settings put global animator_duration_scale 0.0
109-
110-
- name: Run UI Tests
111-
run: |
112-
# Verify device is online
113-
adb devices
114-
115-
# Install app
116-
./gradlew installDebug
117-
118-
# Run tests
119-
./gradlew connectedDebugAndroidTest
51+
- name: AVD cache
52+
uses: actions/cache@v4
53+
id: avd-cache
54+
with:
55+
path: |
56+
~/.android/avd/*
57+
~/.android/adb*
58+
key: avd-29
12059

121-
- name: Cleanup Docker Container
122-
if: always()
123-
run: |
124-
adb kill-server
125-
docker stop android-container
126-
docker rm android-container
60+
- name: Create AVD and generate snapshot for caching
61+
if: steps.avd-cache.outputs.cache-hit != 'true'
62+
uses: reactivecircus/android-emulator-runner@v2
63+
with:
64+
api-level: 29
65+
arch: x86_64
66+
force-avd-creation: false
67+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
68+
disable-animations: false
69+
script: echo "Generated AVD snapshot for caching."
70+
71+
- name: Run UI tests on Android Emulator
72+
uses: reactivecircus/android-emulator-runner@v2
73+
with:
74+
api-level: 29
75+
arch: x86_64
76+
force-avd-creation: false
77+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
78+
disable-animations: true
79+
script: |
80+
./gradlew installDebug
81+
./gradlew connectedDebugAndroidTest
12782
12883
- name: Upload UI test report
12984
if: always()

0 commit comments

Comments
 (0)