-
Notifications
You must be signed in to change notification settings - Fork 127
257 lines (219 loc) · 8.3 KB
/
e2e.yml
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
name: E2E
on:
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
e2e-android:
name: Android
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
# In case this is run on a runner without nix
# - uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@v2
# Caching
- uses: actions/cache@v2
with:
path: |
node_modules
ios/Pods
key: ${{ runner.os }}-deps-${{ hashFiles('**/yarn.lock', '**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-deps-
# Installations
- name: Install Node Modules and Pods
run: nix develop -c yarn install
env:
LANG: en_US.UTF-8
# Metro
- name: Start Metro
run: |
nix develop -c sh -c 'yarn start' &
echo "METRO_PID=$!" >> $GITHUB_ENV
# Builds
- run: nix develop -c yarn e2e:build android.emu.debug
# Start Tilt
- name: Tilt CI
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 10
retry_wait_seconds: 45
command: nix develop -c sh -c 'cd dev && tilt ci'
- name: Tilt Server
run: |
lsof -ti:10350 | xargs kill -9 || true
nix develop -c sh -c 'cd dev && tilt up' &
echo "TILT_SERVER_PID=$!" >> $GITHUB_ENV
# Tests on Android Emulator
- name: Start Android Emulator
run: |
nix develop -c sh -c 'emulator -avd Pixel_API_34 -gpu swiftshader -wipe-data -no-boot-anim' &
nix develop -c adb wait-for-device
- name: Run Detox Tests on Android Emulator
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
retry_wait_seconds: 1
max_attempts: 3
command: |
rm -rf android-recordings || true
nix develop -c tilt trigger dev-setup
nix develop -c tilt wait --timeout 5m --for=condition=Ready uiresources dev-setup
nix develop -c yarn e2e:test android.emu.debug -d --take-screenshots all --record-videos all --record-logs all --artifacts-location android-recordings
- name: Kill Android Emulator
if: always()
continue-on-error: true
run: nix develop -c adb emu kill
- uses: actions/upload-artifact@v4
if: always()
with:
name: android-recordings
path: android-recordings
# Upload recordings to GCS bucket
- uses: "google-github-actions/auth@v2"
if: always()
with:
credentials_json: "${{ secrets.BUILD_ARTIFACTS_BUCKET_KEY }}"
- uses: "google-github-actions/upload-cloud-storage@v2"
if: always()
with:
path: android-recordings
predefinedAcl: publicRead
glob: "**/*.mp4"
headers: |-
content-type: video/mp4
destination: galoy-mobile-recordings/android-recordings/${{ github.run_id }}
- name: Append Direct Links to GitHub Actions Summary
if: always()
run: |
# Define the base URL for the uploaded files in the GCS bucket
BASE_URL="https://storage.googleapis.com/galoy-mobile-recordings/android-recordings/${{ github.run_id }}/android-recordings"
echo "## Android Recordings" >> $GITHUB_STEP_SUMMARY
find android-recordings -type f -name "*.mp4" | while read file; do
# Extract the relative path of the file within the android-recordings folder
RELATIVE_PATH="${file#android-recordings/}"
# Construct the direct URL for the file
FILE_URL="${BASE_URL}/${RELATIVE_PATH}"
TEST_NAME=$(echo "$RELATIVE_PATH" | sed -E 's|.*/(.*)/test\.mp4|\1|')
# Append the URL to the GitHub Actions summary
echo "- $TEST_NAME [Recording](<$FILE_URL>)" >> $GITHUB_STEP_SUMMARY
done
# Cleanup
- name: Terminate Metro
if: always()
continue-on-error: true
run: kill $METRO_PID
- name: Cleanup
if: always()
continue-on-error: true
run: |
kill $METRO_PID || true
kill $TILT_SERVER_PID || true
nix develop -c sh -c 'cd dev && tilt down' || true
docker rm -f $(docker ps -aq) || true
lsof -ti:10350,8080,8081 | xargs kill -9 || true
e2e-ios:
name: iOS
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
# In case this is run on a runner without nix
# - uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@v2
# Caching
- uses: actions/cache@v2
with:
path: |
node_modules
ios/Pods
key: ${{ runner.os }}-deps-${{ hashFiles('**/yarn.lock', '**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-deps-
# Installations
- name: Install Node Modules and Pods
run: nix develop -c yarn install
env:
LANG: en_US.UTF-8
# Metro
- name: Start Metro
run: |
nix develop -c sh -c 'yarn start' &
echo "METRO_PID=$!" >> $GITHUB_ENV
# Builds
- run: nix develop -c yarn e2e:build ios.sim.debug
# Start Tilt
- name: Tilt CI
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 10
retry_wait_seconds: 45
command: nix develop -c sh -c 'cd dev && tilt ci'
- name: Tilt Server
run: |
lsof -ti:10350 | xargs kill -9 || true
nix develop -c sh -c 'cd dev && tilt up' &
echo "TILT_SERVER_PID=$!" >> $GITHUB_ENV
# Tests on iOS Simulator
- name: Run Detox Tests on iOS Simulator
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
retry_wait_seconds: 1
max_attempts: 3
command: |
rm -rf ios-recordings || true
nix develop -c tilt trigger dev-setup
nix develop -c tilt wait --timeout 5m --for=condition=Ready uiresources dev-setup
nix develop -c yarn e2e:test ios.sim.debug -d -R 5 --take-screenshots all --record-videos all --record-logs all --artifacts-location ios-recordings
- run: killall Simulator
if: always()
continue-on-error: true
- uses: actions/upload-artifact@v4
if: always()
with:
name: ios-recordings
path: ios-recordings
# Upload recordings to GCS bucket
- uses: "google-github-actions/auth@v2"
if: always()
with:
credentials_json: "${{ secrets.BUILD_ARTIFACTS_BUCKET_KEY }}"
- uses: "google-github-actions/upload-cloud-storage@v2"
if: always()
with:
path: ios-recordings
predefinedAcl: publicRead
glob: "**/*.mp4"
headers: |-
content-type: video/mp4
destination: galoy-mobile-recordings/ios-recordings/${{ github.run_id }}
- name: Append Direct Links to GitHub Actions Summary
if: always()
run: |
# Define the base URL for the uploaded files in the GCS bucket
BASE_URL="https://storage.googleapis.com/galoy-mobile-recordings/ios-recordings/${{ github.run_id }}/ios-recordings"
echo "## iOS Recordings" >> $GITHUB_STEP_SUMMARY
find ios-recordings -type f -name "*.mp4" | while read file; do
# Extract the relative path of the file within the ios-recordings folder
RELATIVE_PATH="${file#ios-recordings/}"
# Construct the direct URL for the file
FILE_URL="${BASE_URL}/${RELATIVE_PATH}"
TEST_NAME=$(echo "$RELATIVE_PATH" | sed -E 's|.*/(.*)/test\.mp4|\1|')
# Append the URL to the GitHub Actions summary
echo "- $TEST_NAME [Recording](<$FILE_URL>)" >> $GITHUB_STEP_SUMMARY
done
# Cleanup
- name: Cleanup
if: always()
continue-on-error: true
run: |
kill $METRO_PID || true
kill $TILT_SERVER_PID || true
nix develop -c sh -c 'cd dev && tilt down' || true
docker rm -f $(docker ps -aq) || true
lsof -ti:10350,8080,8081 | xargs kill -9 || true