-
Notifications
You must be signed in to change notification settings - Fork 281
339 lines (278 loc) · 10.2 KB
/
test-e2e.yaml
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
name: Test E2E
on:
workflow_dispatch:
pull_request:
jobs:
build:
name: Build on Java ${{ matrix.java-version }}
runs-on: macos-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
java-version: [11, 17]
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: ${{ matrix.java-version }}
cache: gradle
- name: Build xctest-runner
run: ./maestro-ios-xctest-runner/build-maestro-ios-runner.sh | xcbeautify
- name: Build Maestro CLI
run: ./gradlew :maestro-cli:distZip
- name: Upload zipped Maestro CLI artifact
uses: actions/upload-artifact@v4
with:
name: maestro-cli-jdk${{ matrix.java-version }}-run_id${{ github.run_id }}
path: maestro-cli/build/distributions/maestro.zip
retention-days: 1
- name: Upload build/Products to artifacts
uses: actions/upload-artifact@v4
with:
name: build__Products-jdk${{ matrix.java-version }}
path: build/Products
retention-days: 1
test-android:
name: Test on Android
runs-on: ubuntu-latest
needs: build
timeout-minutes: 60
env:
ANDROID_HOME: /home/runner/androidsdk
ANDROID_SDK_ROOT: /home/runner/androidsdk
ANDROID_OS_IMAGE: system-images;android-28;google_apis;x86_64
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: Clone repository (only needed for the e2e directory)
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: maestro-cli-jdk11-run_id${{ github.run_id }}
- name: Add Maestro CLI executable to PATH
run: |
unzip maestro.zip -d maestro_extracted
echo "$PWD/maestro_extracted/maestro/bin" >> $GITHUB_PATH
- name: Check if Maestro CLI executable starts up
run: |
maestro --help
maestro --version
- name: Set up mobile-dev-inc/bartek-scripts (for install_android_sdk script)
run: |
git clone https://github.com/mobile-dev-inc/bartek-scripts.git $HOME/scripts
echo "$HOME/scripts/bin" >> $GITHUB_PATH
- name: Set up android-wait-for-emulator script
run: |
curl -fsSl -O https://raw.githubusercontent.com/travis-ci/travis-cookbooks/master/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
chmod +x ./android-wait-for-emulator
mv ./android-wait-for-emulator $HOME/scripts/bin
- name: Set up Android Command-line Tools
run: |
# v8, latest working on Java 8. Source: https://stackoverflow.com/a/78890086/7009800
install_android_sdk https://dl.google.com/android/repository/commandlinetools-linux-9123335_latest.zip
echo "$ANDROID_HOME/cmdline-tools/latest/bin:$PATH" >> $GITHUB_PATH
- name: Set up Android SDK components
run: |
yes | sdkmanager --install emulator
echo "$ANDROID_HOME/emulator" >> $GITHUB_PATH
yes | sdkmanager --install "platform-tools"
echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH
yes | sdkmanager --install "platforms;android-34"
yes | sdkmanager --install "$ANDROID_OS_IMAGE"
- name: Create AVD
run: |
avdmanager -s create avd \
--package "$ANDROID_OS_IMAGE" \
--name "MyAVD"
cat << EOF >> ~/.android/avd/MyAVD.avd/config.ini
hw.cpu.ncore=2
hw.gpu.enabled=yes
hw.gpu.mode=swiftshader_indirect
hw.ramSize=3072
disk.dataPartition.size=4G
vm.heapSize=576
hw.lcd.density=440
hw.lcd.height=2220
hw.lcd.width=1080
EOF
- name: Run AVD
run: |
emulator @MyAVD \
-verbose -no-snapshot-save -no-window -noaudio -no-boot-anim -accel on -camera-back none \
>~/emulator_stdout.log \
2>~/emulator_stderr.log &
- name: Wait for AVD to start up
run: |
android-wait-for-emulator
# This is also a prerequiste
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
- name: Download apps
working-directory: ${{ github.workspace }}/e2e
run: ./download_apps
- name: Install apps
working-directory: ${{ github.workspace }}/e2e
run: ./install_apps android
- name: Start screen recording of AVD
run: |
adb shell screenrecord /sdcard/screenrecord.mp4 &
echo $! > ~/screenrecord.pid
- name: Run tests
working-directory: ${{ github.workspace }}/e2e
timeout-minutes: 20
run: ./run_tests android
- name: Stop screen recording of AVD
if: success() || failure()
run: |
kill -SIGINT "$(cat ~/screenrecord.pid)" || echo "failed to kill screenrecord: code $?" && exit 0
sleep 5 # prevent video file corruption
adb pull /sdcard/screenrecord.mp4 ~/screenrecord.mp4
- name: Upload ~/.maestro artifacts
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: maestro-root-dir-android
path: ~/.maestro
retention-days: 7
include-hidden-files: true
- name: Upload screen recording of AVD
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: maestro-screenrecord-android.mp4
path: ~/screenrecord.mp4
retention-days: 7
test-ios:
name: Test on iOS
runs-on: macos-latest
needs: build
timeout-minutes: 120
if: ${{ false }}
env:
MAESTRO_DRIVER_STARTUP_TIMEOUT: 240000 # 240s
MAESTRO_CLI_LOG_PATTERN_CONSOLE: '%d{HH:mm:ss.SSS} [%5level] %logger.%method: %msg%n'
steps:
- name: Clone repository (only needed for the e2e directory)
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: maestro-cli-jdk11-run_id${{ github.run_id }}
- name: Add Maestro CLI executable to PATH
run: |
unzip maestro.zip -d maestro_extracted
echo "$PWD/maestro_extracted/maestro/bin" >> $GITHUB_PATH
- name: Check if Maestro CLI executable starts up
run: |
maestro --help
maestro --version
- name: Run simulator
run: xcrun simctl boot iPhone\ 15
- name: Wait for simulator to boot
run: xcrun simctl bootstatus iPhone\ 15
- name: Download apps
working-directory: ${{ github.workspace }}/e2e
run: ./download_apps
- name: Install apps
working-directory: ${{ github.workspace }}/e2e
run: ./install_apps ios
- name: Start screen recording
run: |
xcrun simctl io booted recordVideo --codec h264 ~/screenrecord.mp4 &
echo $! > ~/screenrecord.pid
- name: Run tests
working-directory: ${{ github.workspace }}/e2e
timeout-minutes: 120
run: ./run_tests ios
- name: Stop screen recording
if: success() || failure()
run: kill -SIGINT "$(cat ~/screenrecord.pid)"
- name: Upload ~/.maestro artifacts
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: maestro-root-dir-ios
path: ~/.maestro
retention-days: 7
include-hidden-files: true
- name: Upload xc test runner logs
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: xctest_runner_logs
path: ~/Library/Logs/maestro/xctest_runner_logs
retention-days: 7
include-hidden-files: true
- name: Upload screen recording of AVD
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: maestro-screenrecord-ios.mp4
path: ~/screenrecord.mp4
retention-days: 7
test-ios-xctest-runner:
name: Test on iOS (XCTest Runner only)
runs-on: macos-latest
needs: build
timeout-minutes: 30
steps:
- name: Clone repository (only needed for the e2e directory)
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
- name: Download Maestro artifact
uses: actions/download-artifact@v4
with:
name: maestro-cli-jdk11-run_id${{ github.run_id }}
- name: Download build/Products artifact
uses: actions/download-artifact@v4
with:
name: build__Products-jdk11
path: build/Products
- name: Add Maestro CLI executable to PATH
run: |
unzip maestro.zip -d maestro_extracted
echo "$PWD/maestro_extracted/maestro/bin" >> $GITHUB_PATH
- name: Check if Maestro CLI executable starts up
run: |
maestro --help
maestro --version
- name: Run simulator
run: xcrun simctl boot iPhone\ 15
- name: Wait for simulator to boot
run: xcrun simctl bootstatus iPhone\ 15
- name: Run tests
timeout-minutes: 15
run: ./maestro-ios-xctest-runner/test-maestro-ios-runner.sh
- name: Upload xc test runner logs
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-ios-xctest-runner__xctest_runner_logs
path: ~/Library/Logs/maestro/xctest_runner_logs
retention-days: 7
include-hidden-files: true