-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (189 loc) · 6.89 KB
/
maestro-android.yml
File metadata and controls
221 lines (189 loc) · 6.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Maestro E2E Android
on:
push:
branches: [master]
pull_request:
branches: [master]
types: [opened, reopened, synchronize]
workflow_dispatch:
concurrency:
group: maestro-android-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
e2e-android:
name: Test on Android
runs-on: ubuntu-latest
timeout-minutes: 60
env:
ANDROID_HOME: /home/runner/androidsdk
ANDROID_SDK_ROOT: /home/runner/androidsdk
ANDROID_AVD_HOME: /mnt/avd
ANDROID_OS_IMAGE: system-images;android-32;google_apis;x86_64
ANDROID_PLATFORM: platforms;android-36
steps:
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Checkout
uses: actions/checkout@v4
- name: Free disk space
run: |
df -h
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf /opt/ghc || true
sudo rm -rf /usr/local/.ghcup || true
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
sudo docker system prune -af || true
sudo mkdir -p /mnt/avd
sudo chmod -R 777 /mnt/avd
df -h
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.19.4"
cache: npm
- name: Install JS dependencies
run: npm ci --ignore-scripts --prefer-offline --no-audit
- name: Ensure Android native project
run: |
if [ ! -d android ]; then
npx expo prebuild -p android --clean --no-install --non-interactive
fi
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "17"
- name: Install Maestro CLI
run: |
curl --proto '=https' --tlsv1.2 -fsSL "https://get.maestro.mobile.dev" | bash
echo "$HOME/.maestro/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.maestro/bin:$PATH"
"$HOME/.maestro/bin/maestro" --version
- name: Set up bartek-scripts
run: |
git clone --depth 1 https://github.com/mobile-dev-inc/bartek-scripts.git $HOME/scripts
echo "$HOME/scripts/bin" >> "$GITHUB_PATH"
- name: Set up Android command-line tools
run: |
install_android_sdk https://dl.google.com/android/repository/commandlinetools-linux-12266719_latest.zip
echo "$ANDROID_HOME/cmdline-tools/latest/bin" >> "$GITHUB_PATH"
echo "$ANDROID_HOME/emulator" >> "$GITHUB_PATH"
echo "$ANDROID_HOME/platform-tools" >> "$GITHUB_PATH"
- name: Set up Android SDK components
run: |
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH"
yes | sdkmanager --licenses
sdkmanager --install \
"emulator" \
"platform-tools" \
"$ANDROID_PLATFORM" \
"build-tools;36.0.0" \
"$ANDROID_OS_IMAGE"
- name: Create local.properties
run: |
echo "sdk.dir=$ANDROID_HOME" > android/local.properties
cat android/local.properties
- name: Build Android debug APK
working-directory: android
run: |
chmod +x ./gradlew
./gradlew assembleDebug \
-PreactNativeArchitectures=x86_64 \
--stacktrace \
--console=plain \
--no-daemon \
--max-workers=2
- name: Create AVD
run: |
export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH"
mkdir -p "$ANDROID_AVD_HOME"
echo "no" | avdmanager create avd \
--force \
--package "$ANDROID_OS_IMAGE" \
--name "MyAVD" \
--sdcard 512M
cat << EOF >> "$ANDROID_AVD_HOME/MyAVD.avd/config.ini"
hw.cpu.ncore=2
hw.gpu.enabled=yes
hw.gpu.mode=swiftshader_indirect
hw.ramSize=3072
vm.heapSize=576
disk.dataPartition.size=2048M
hw.lcd.density=440
hw.lcd.height=2220
hw.lcd.width=1080
fastboot.forceColdBoot=yes
showDeviceFrame=no
EOF
- name: Run AVD
run: |
export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH"
emulator @MyAVD \
-verbose \
-no-snapshot \
-no-window \
-no-audio \
-no-boot-anim \
-accel on \
-camera-back none \
-partition-size 2048 \
-qemu -m 3072 \
> ~/emulator_stdout.log \
2> ~/emulator_stderr.log &
- name: Wait for AVD to start up
run: |
export PATH="$ANDROID_HOME/platform-tools:$PATH"
for i in {1..120}; do
adb devices
if adb devices | grep -q "emulator-.*device"; then
echo "Emulator device online"
break
fi
sleep 2
done
adb wait-for-device
adb shell 'while [[ "$(getprop sys.boot_completed | tr -d "\r")" != "1" ]]; do sleep 1; done;' && echo "Emulator booted"
while true; do
adb shell service list | grep 'package' && echo 'service "package" is active!' && break
echo 'waiting for service "package" to start'
sleep 1
done
adb shell settings put global window_animation_scale 0 || true
adb shell settings put global transition_animation_scale 0 || true
adb shell settings put global animator_duration_scale 0 || true
- name: Install app
run: |
adb install -r android/app/build/outputs/apk/debug/*.apk
- name: Start screen recording of AVD
run: |
adb shell screenrecord /sdcard/screenrecord.mp4 &
echo $! > ~/screenrecord.pid
- name: Run tests
timeout-minutes: 20
run: |
mkdir -p .maestro/output
maestro test .maestro/automated/suite.yaml \
--format junit \
--output .maestro/output/results.xml
- name: Stop screen recording of AVD
if: success() || failure()
run: |
kill -SIGINT "$(cat ~/screenrecord.pid)" || echo "failed to kill screenrecord"
sleep 5
adb pull /sdcard/screenrecord.mp4 ~/screenrecord.mp4 || true
- name: Upload Maestro artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: maestro-android-artifacts
path: |
.maestro/output/
~/.maestro
~/emulator_stdout.log
~/emulator_stderr.log
~/screenrecord.mp4
if-no-files-found: ignore
include-hidden-files: true