forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
410 lines (409 loc) · 16.7 KB
/
e2e_lighthouse_performance_acceptance_tests.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
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
name: End-to-End, Lighthouse CI performance and Acceptance tests
on:
merge_group:
types: [checks_requested]
push:
branches:
- develop
- release-*
pull_request:
branches:
- develop
- release-*
jobs:
check_test_suites_to_run:
uses: ./.github/workflows/check_test_suites_to_run.yml
build:
needs: check_test_suites_to_run
if: ${{ fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).e2e.count > 0 ||
fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).lighthouse_performance.count > 0 ||
fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).acceptance.count > 0 }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8 with pip cache
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
cache: 'pip'
cache-dependency-path: |
requirements.in
requirements.txt
requirements_dev.in
requirements_dev.txt
- name: Merge develop branch into the current branch
uses: ./.github/actions/merge
- name: Cache node modules and third_party/static
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: |
/home/runner/work/oppia/yarn_cache
/home/runner/work/oppia/oppia/third_party/static
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock', 'dependencies.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Oppia dependencies
uses: ./.github/actions/install-oppia-dependencies
- name: Install chrome
run: python -m scripts.install_chrome_for_ci
- name: Install ffmpeg
run: sudo apt install ffmpeg
- name: Build Webpack
run: python -m scripts.build --prod_env
- name: Zip build files
# We avoid using ../ or absolute paths because unzip treats these as
# security issues and will refuse to follow them.
run: |
zip -rqy build_files.zip oppia/third_party oppia_tools oppia/build oppia/webpack_bundles oppia/proto_files oppia/app.yaml oppia/assets/hashes.json oppia/proto_files oppia/extensions/classifiers/proto/* oppia/backend_prod_files oppia/dist
working-directory: /home/runner/work/oppia
- name: Upload build files artifact
uses: actions/upload-artifact@v3
with:
name: build_files
path: /home/runner/work/oppia/build_files.zip
retention-days: 1
e2e_test:
needs: [check_test_suites_to_run, build]
if: ${{ fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).e2e.count > 0 }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
suite: ${{ fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).e2e.suites }}
name: e2e_test (${{ matrix.os }}, ${{ matrix.suite.name }})
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8 with pip cache
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
cache: 'pip'
cache-dependency-path: |
requirements.in
requirements.txt
requirements_dev.in
requirements_dev.txt
- name: Merge develop branch into the current branch
uses: ./.github/actions/merge
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: /home/runner/work/oppia/yarn_cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Attempt to download build files artifact
id: download_artifact_1
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: build_files
path: /home/runner/work/oppia/
- name: Unzip build files
if: steps.download_artifact_1.outcome != 'failure'
run: |
ls -la
unzip build_files.zip
rm build_files.zip
echo "Files in ./:"
ls -la .
echo "Files in oppia_tools:"
ls -la oppia_tools
echo "Files in oppia:"
ls -la oppia
echo "Files in build:"
ls -la oppia/build
echo "Files in third_party:"
ls -la oppia/third_party
working-directory: /home/runner/work/oppia
shell: bash
- name: Install Oppia dependencies
uses: ./.github/actions/install-oppia-dependencies
- name: Install chrome
run: python -m scripts.install_chrome_for_ci
- name: Install ffmpeg
run: sudo apt install ffmpeg
- name: (Artifact re-build) Cache third_party/static
if: steps.download_artifact_1.outcome == 'failure'
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: /home/runner/work/oppia/oppia/third_party/static
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('dependencies.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: (Artifact re-build) Build Webpack
if: steps.download_artifact_1.outcome == 'failure'
run: python -m scripts.build --prod_env
- name: Run E2E Test ${{ matrix.suite.name }}
uses: oppia/retry@a9fb265410e634c84ee90f3e87f323fde0541037
with:
max_attempts: 2
substrings_indicating_flaky_execution: ${{ matrix.suite.flaky_indicators || '' }}
command: >
VIDEO_RECORDING_IS_ENABLED=0;
xvfb-run -a --server-args="-screen 0, 1285x1000x24"
python -m scripts.run_e2e_tests --skip-install
--skip-build --suite=${{ matrix.suite.name }} --prod_env
- name: Uploading webdriverio-video as Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: webdriverio-video
path: /home/runner/work/oppia/webdriverio-video
- name: Uploading webdriverio screenshots as Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: webdriverio-screenshots
path: /home/runner/work/oppia/webdriverio-screenshots
- name: Uploading webpack bundles as an artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: webpack-bundles
path: /home/runner/work/oppia/oppia/build
- name: Report failure if failed on oppia/oppia develop branch
if: ${{ failure() && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}}
uses: ./.github/actions/send-webhook-notification
with:
message: "An E2E test failed on the upstream develop branch."
webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }}
lighthouse_performance:
needs: [check_test_suites_to_run, build]
if: ${{ fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).lighthouse_performance.count > 0 }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
suite: ${{ fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).lighthouse_performance.suites }}
name: lighthouse (${{ matrix.os }}, ${{ matrix.suite.name }})
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
- name: Merge develop branch into the current branch
uses: ./.github/actions/merge
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: /home/runner/work/oppia/yarn_cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Attempt to download build files artifact
id: download_artifact_1
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: build_files
path: /home/runner/work/oppia/
- name: Unzip build files
if: steps.download_artifact_1.outcome != 'failure'
run: |
ls -la
unzip build_files.zip
rm build_files.zip
echo "Files in ./:"
ls -la .
echo "Files in oppia_tools:"
ls -la oppia_tools
echo "Files in oppia:"
ls -la oppia
echo "Files in build:"
ls -la oppia/build
echo "Files in third_party:"
ls -la oppia/third_party
working-directory: /home/runner/work/oppia
shell: bash
- name: (Artifact re-build) Cache third_party/static
if: steps.download_artifact_1.outcome == 'failure'
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: /home/runner/work/oppia/oppia/third_party/static
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('dependencies.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: (Artifact re-build) Build Webpack
if: steps.download_artifact_1.outcome == 'failure'
run: python -m scripts.build --prod_env
- name: Install Oppia dependencies
uses: ./.github/actions/install-oppia-dependencies
- name: Install chrome
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
run: python -m scripts.install_chrome_for_ci
- name: Run Lighthouse performance checks shard ${{ matrix.suite.name }}
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
run: python -m scripts.run_lighthouse_tests --mode performance --skip_build --record_screen --pages ${{ join(matrix.suite.pages_to_run, ',') }}
- name: Uploading puppeteer video as Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: lhci-puppeteer-video
path: /home/runner/work/oppia/lhci-puppeteer-video/video.mp4
- name: Report failure if failed on oppia/oppia develop branch
if: ${{ failure() && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}}
uses: ./.github/actions/send-webhook-notification
with:
message: "A Lighthouse test failed on the upstream develop branch."
webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }}
acceptance_test:
needs: [check_test_suites_to_run, build]
if: ${{ fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).acceptance.count > 0 }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
suite: ${{ fromJson(needs.check_test_suites_to_run.outputs.test_suites_to_run).acceptance.suites }}
name: acceptance_test (${{ matrix.os }}, ${{ matrix.suite.name }})
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8 with pip cache
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
cache: 'pip'
cache-dependency-path: |
requirements.in
requirements.txt
requirements_dev.in
requirements_dev.txt
- name: Merge develop branch into the current branch
uses: ./.github/actions/merge
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: /home/runner/work/oppia/yarn_cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Attempt to download build files artifact
id: download_artifact_1
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: build_files
path: /home/runner/work/oppia/
- name: Unzip build files
if: steps.download_artifact_1.outcome != 'failure'
run: |
ls -la
unzip build_files.zip
rm build_files.zip
echo "Files in ./:"
ls -la .
echo "Files in oppia_tools:"
ls -la oppia_tools
echo "Files in oppia:"
ls -la oppia
echo "Files in build:"
ls -la oppia/build
echo "Files in third_party:"
ls -la oppia/third_party
working-directory: /home/runner/work/oppia
shell: bash
- name: Install Oppia dependencies
uses: ./.github/actions/install-oppia-dependencies
- name: (Artifact re-build) Cache third_party/static
if: steps.download_artifact_1.outcome == 'failure'
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: /home/runner/work/oppia/oppia/third_party/static
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('dependencies.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: (Artifact re-build) Build Webpack
if: steps.download_artifact_1.outcome == 'failure'
run: python -m scripts.build --prod_env
- name: Run Desktop Acceptance Test ${{ matrix.suite.name }}
run: xvfb-run -a --server-args="-screen 0, 1285x1000x24" python -m scripts.run_acceptance_tests --skip-build --suite=${{ matrix.suite.name }} --prod_env
- name: Uploading generated test to angular module mapping as an artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: generated-test-to-angular-module-mapping
path: /home/runner/work/oppia/oppia/core/tests/test-modules-mappings/acceptance/${{ matrix.suite.name }}.txt
- name: Run Mobile Acceptance Test ${{ matrix.suite.name }}
run: xvfb-run -a --server-args="-screen 0, 1285x1000x24" python -m scripts.run_acceptance_tests --skip-build --suite=${{ matrix.suite.name }} --prod_env --mobile
- name: Uploading webpack bundles as an artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: webpack-bundles
path: /home/runner/work/oppia/oppia/build
- name: Report failure if failed on oppia/oppia develop branch
if: ${{
failure() &&
github.event_name == 'push' &&
github.repository == 'oppia/oppia' &&
github.ref == 'refs/heads/develop'
}}
uses: ./.github/actions/send-webhook-notification
with:
message: "An acceptance test failed on the upstream develop branch."
webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }}
check_e2e_lighthouse_performance_acceptance_workflow_status:
needs: [check_test_suites_to_run, build, e2e_test, lighthouse_performance, acceptance_test]
if: always()
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
- name: Merge develop branch into the current branch
uses: ./.github/actions/merge
- name: Check workflow status
uses: ./.github/actions/check-workflow-status
id: check_workflow_status
with:
jobs: ${{ toJson(needs) }}
- name: Fail if workflow status is failure
if: ${{ steps.check_workflow_status.outputs.WORKFLOW_STATUS == 'failure' }}
run: exit 1