@@ -2,12 +2,6 @@ name: Testing E2E Android
2
2
3
3
on :
4
4
workflow_dispatch :
5
- inputs :
6
- clearCaches :
7
- description : " Clear workflow caches where possible"
8
- required : false
9
- type : string
10
-
11
5
pull_request :
12
6
branches :
13
7
- ' **'
@@ -34,29 +28,29 @@ concurrency:
34
28
jobs :
35
29
android :
36
30
name : Android
37
- runs-on : macos-12
31
+ runs-on : ubuntu-latest
38
32
timeout-minutes : 90
39
33
strategy :
40
34
fail-fast : false
41
35
matrix :
42
- # Refactor to make these dynamic with a low/high bracket only on schedule, not push
43
- # For now this is just the fastest combo (api/arch/target/snapshot-warm-time) based on testing
44
- api-level : [30]
36
+ # all APIs below 23, and 27 just do not work
37
+ # 26 does not support performance tracing due to hardware acceleration bugs
38
+ # min-possible + max-possible skew looks like 23 and 34 then
39
+ api-level : [23, 34]
45
40
arch : [x86_64]
46
41
target : [google_apis]
47
- first-boot-delay : [600]
48
42
# This is useful for benchmarking, do 0, 1, 2, etc (up to 256 max job-per-matrix limit) for averages
49
43
iteration : [0]
50
44
env :
51
45
CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
52
46
EMULATOR_COMMAND : " -avd TestingAVD -noaudio -gpu swiftshader_indirect -camera-back none -no-snapshot -no-window -no-boot-anim -nojni -memory 2048 -timezone 'Europe/London' -cores 2"
53
47
EMULATOR_EXECUTABLE : qemu-system-x86_64-headless
54
48
steps :
55
- # macOS13 runners are slooooow
56
- # This is from: https://github.com/actions/runner-images/issues/7971#issuecomment-1824430407
57
- - name : macOS-13-runner speedup
49
+ - name : Enable KVM group perms
58
50
run : |
59
- sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.diagnosticd.plist
51
+ echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
52
+ sudo udevadm control --reload-rules
53
+ sudo udevadm trigger --name-match=kvm
60
54
61
55
- uses : actions/checkout@v4
62
56
with :
@@ -113,31 +107,6 @@ jobs:
113
107
key : ${{ runner.os }}-gradle-v1-${{ hashFiles('yarn.lock', 'tests/android/build.gradle', 'tests/android/app/build.gradle') }}
114
108
restore-keys : ${{ runner.os }}-gradle-v1
115
109
116
- # This appears to be 'Cache Size: ~1230 MB (1290026823 B)' based on watching action logs
117
- # Repo limit is 10GB; branch caches are independent; branches may read default branch cache.
118
- # We don't want branches to evict main branch snapshot, so save on main, read-only all else
119
- - name : AVD cache
120
- uses : actions/cache@v3
121
- id : avd-cache
122
- with :
123
- path : |
124
- ~/.android/avd/*
125
- ~/.android/adb*
126
- key : avd-${{ matrix.api-level }}-${{ matrix.arch }}-${{matrix.target}}-v1-${{ github.event.inputs.clearCaches }}
127
- restore-keys : |
128
- avd-${{ matrix.api-level }}-${{ matrix.arch }}-${{matrix.target}}-v1
129
-
130
- - name : Clear Caches Optionally
131
- if : " ${{ github.event.inputs.clearCaches != '' }}"
132
- shell : bash
133
- run : |
134
- du -sk ~/.gradle
135
- du -sk ~/.android
136
- rm -fr ~/.gradle
137
- rm -fr ~/.android
138
- du -sk ~/.gradle || echo ~/.gradle is gone
139
- du -sk ~/.android || echo ~/.android is gone
140
-
141
110
- name : Build Android App
142
111
uses : nick-fields/retry@v2
143
112
with :
@@ -166,54 +135,8 @@ jobs:
166
135
curl --output /dev/null --silent --head --fail "http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&inlineSourceMap=true"
167
136
echo "...javascript bundle ready."
168
137
169
- - name : AVD Boot and Snapshot Creation
170
- # Only generate a snapshot with a cache miss
171
- # Comment the if out to generate snapshots on branch for performance testing
172
- if : " ${{ github.event.inputs.clearCaches != '' || (steps.avd-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main') }}"
173
- uses : reactivecircus/android-emulator-runner@v2
174
- with :
175
- api-level : ${{ matrix.api-level }}
176
- avd-name : TestingAVD
177
- force-avd-creation : false
178
- target : ${{ matrix.target }}
179
- arch : ${{ matrix.arch }}
180
- emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
181
- sdcard-path-or-size : 100M
182
- disable-animations : true
183
- # Give the emulator a little time to run and do first boot stuff before taking snapshot
184
- script : |
185
- $ANDROID_HOME/platform-tools/adb logcat '*:D' -d > adb-snapshot-log.txt
186
- $ANDROID_HOME/platform-tools/adb logcat --clear
187
- echo "Generated AVD snapshot for caching."
188
-
189
- # This step is separate so pure install time may be calculated as a step
190
- - name : Emulator Snapshot After Firstboot Warmup
191
- # Only generate a snapshot for saving with a cache miss
192
- # Switch the if statements via comment if generating snapshots for performance testing
193
- # if: matrix.first-boot-delay != '0'
194
- if : " ${{ github.event.inputs.clearCaches != '' || (steps.avd-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main') }}"
195
- env :
196
- FIRST_BOOT_DELAY : ${{ matrix.first-boot-delay }}
197
- uses : reactivecircus/android-emulator-runner@v2
198
- with :
199
- api-level : ${{ matrix.api-level }}
200
- avd-name : TestingAVD
201
- force-avd-creation : false
202
- target : ${{ matrix.target }}
203
- arch : ${{ matrix.arch }}
204
- emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
205
- sdcard-path-or-size : 100M
206
- disable-animations : true
207
- # Give the emulator a little time to run and do first boot stuff before taking snapshot
208
- # The zygote restart makes sure zygote has correct heap size as a workaround for android emulator init bug
209
- script : |
210
- $ANDROID_HOME/platform-tools/adb shell su root "setprop ctl.restart zygote"
211
- sleep $FIRST_BOOT_DELAY
212
- $ANDROID_HOME/platform-tools/adb logcat '*:D' -d > adb-warmup-log.txt
213
- $ANDROID_HOME/platform-tools/adb logcat --clear
214
- echo "First boot warmup completed."
215
-
216
138
- name : Test Tapper
139
+ # Detox uses Espresso to choreograph UI events, we send a stream of taps to keep choreography moving quickly
217
140
# Run this outside the emulator runner so the emulator runner does not wait on it for cleanup
218
141
run : |
219
142
nohup sh -c "until false; do $ANDROID_HOME/platform-tools/adb shell input tap 100 800; sleep 0.2; done" &
@@ -225,17 +148,17 @@ jobs:
225
148
with :
226
149
api-level : ${{ matrix.api-level }}
227
150
avd-name : TestingAVD
228
- force-avd-creation : false
229
151
target : ${{ matrix.target }}
230
152
arch : ${{ matrix.arch }}
231
- emulator-options : -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
232
- sdcard-path-or-size : 100M
233
- disable-animations : true
234
- # Detox uses Espresso to choreograph steps in reaction to UI events, so we need to send a stream of taps.
153
+ pre-emulator-launch-script : |
154
+ sudo mkdir /mnt/avd
155
+ sudo chown $USER:$USER /mnt/avd
156
+ mkdir -p $HOME/.android
157
+ ln -s /mnt/avd $HOME/.android/avd
235
158
script : |
236
159
$ANDROID_HOME/platform-tools/adb devices
237
160
nohup sh -c "$ANDROID_HOME/platform-tools/adb logcat '*:D' > adb-log.txt" &
238
- yarn tests:android:test-cover
161
+ yarn tests:android:test-cover --headless
239
162
yarn tests:android:test:jacoco-report
240
163
241
164
- uses : codecov/codecov-action@v3
0 commit comments