-
Notifications
You must be signed in to change notification settings - Fork 305
721 lines (608 loc) · 28.7 KB
/
reusable-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
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
# Description: this is a reusable workflow that runs e2e tests.
#
# See `./test-prs.yml` to see an example usage.
on:
pull_request:
inputs:
commit:
# commit to run tests against
required: true
type: string
repository:
# repository to run tests against (possibly a fork of amplify-ui)
required: true
type: string
skip-changed-packages-check:
# skip checking changed packages job if true
required: false
default: 'false'
type: string
secrets:
AUTH_E2E_ROLE_ARN:
required: true
GEO_E2E_ROLE_ARN:
required: true
STORAGE_E2E_ROLE_ARN:
required: true
DATASTORE_E2E_ROLE_ARN:
required: true
IN_APP_MESSAGING_E2E_ROLE_ARN:
required: true
LIVENESS_E2E_ROLE_ARN:
required: true
DOMAIN:
required: true
PHONE_NUMBER:
required: true
USERNAME:
required: true
NEW_PASSWORD:
required: true
VALID_PASSWORD:
required: true
SITE_URL:
required: true
DOCSEARCH_DOCS_APP_ID:
required: true
DOCSEARCH_DOCS_API_KEY:
required: true
DOCSEARCH_DOCS_INDEX_NAME:
required: true
jobs:
e2e:
# Only run e2e tests if unit tests pass
runs-on: ubuntu-latest
environment: ci
env:
NODE_ENV: test
strategy:
# Run each examples (e.g. `next-example`) which uses a library (e.g. `@aws-amplify/ui-react`)
# BUT, Exclude `@todo-${{ package }}` tests in PRs
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-environment-variables-in-a-matrix
matrix:
include:
- example: angular
package: angular
tags: '@angular and not @todo-angular'
- example: next
package: react
tags: '@react and not @todo-react'
- example: vue
package: vue
tags: '@vue and not @todo-vue'
steps:
- name: Checkout Amplify UI
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
# For `pull_request_target`, we want ref to point to `pull_request.head.ref` because `github.ref`
# always points to the target branch.
# See: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
ref: ${{ inputs.commit }}
repository: ${{ inputs.repository }}
persist-credentials: false
- name: Next.js Cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Setup Node.js 16
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 https://github.com/actions/setup-node/commit/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version: 16
cache: 'yarn'
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
- name: Restore cypress runner Cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: restore-cypress-cache
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Restore node_modules cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: restore-cache
with:
path: |
./node_modules
**/node_modules
key: ${{ runner.os }}-nodemodules-${{ inputs.commit }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
- name: Restore ui/dist cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: restore-ui-cache
with:
path: ./packages/ui/dist
key: ${{ runner.os }}-ui-${{ inputs.commit }}
- name: Restore ${{ matrix.package }}/dist cache
id: restore-package-cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ./packages/${{ matrix.package }}/dist
key: ${{ runner.os }}-${{ matrix.package }}-${{ inputs.commit }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Install packages
if: steps.restore-cache.outputs.cache-hit != 'true' || steps.restore-cypress-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/install-with-retries
with:
skip-cypress-binary: false
- name: Build @aws-amplify/ui package
if: steps.restore-ui-cache.outputs.cache-hit != 'true'
run: yarn ui build
- name: Build react-core package
if: ${{ matrix.package == 'react' }}
run: yarn react-core build
- name: Build react-core-notifications package
if: ${{ matrix.package == 'react' }}
run: yarn react-core-notifications build
- name: Build ${{ matrix.package }} package
if: steps.restore-package-cache.outputs.cache-hit != 'true'
run: yarn ${{ matrix.package }} build
- name: Build react-notifications package
if: ${{ matrix.package == 'react' }}
run: yarn react-notifications build
- name: Build react-geo package
if: ${{ matrix.package == 'react' }}
run: yarn react-geo build
- name: Build react-storage package
if: ${{ matrix.package == 'react' }}
run: yarn react-storage build
- name: Build react-liveness package
if: ${{ matrix.package == 'react' }}
run: yarn react-liveness build
- name: Add Amplify CLI
run: yarn global add @aws-amplify/cli
- name: Configure auth credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 https://github.com/aws-actions/configure-aws-credentials/commit/e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
with:
aws-region: us-east-2
role-to-assume: ${{ secrets.AUTH_E2E_ROLE_ARN }}
# Amplify CLI does not support headless pull with temporary credentials
# when useProfile is false.
# See: https://github.com/aws-amplify/amplify-cli/issues/11009.
- name: Create temp AWS Profile
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \
aws configure set aws_session_token $AWS_SESSION_TOKEN && \
aws configure set default.region $AWS_REGION
- name: Pull down Auth AWS environments
run: yarn environments auth pull
- name: Configure geo credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 https://github.com/aws-actions/configure-aws-credentials/commit/e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
with:
aws-region: us-east-2
role-to-assume: ${{ secrets.GEO_E2E_ROLE_ARN }}
- name: Create temp AWS profile
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \
aws configure set aws_session_token $AWS_SESSION_TOKEN && \
aws configure set default.region $AWS_REGION
- name: Pull down Geo AWS environments
run: yarn environments geo pull
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 https://github.com/aws-actions/configure-aws-credentials/commit/e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
with:
aws-region: us-east-2
role-to-assume: ${{ secrets.STORAGE_E2E_ROLE_ARN }}
- name: Create temp AWS profile
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \
aws configure set aws_session_token $AWS_SESSION_TOKEN && \
aws configure set default.region $AWS_REGION
- name: Pull down Storage AWS environments
run: yarn environments storage pull
- name: Configure datastore credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 https://github.com/aws-actions/configure-aws-credentials/commit/e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
with:
aws-region: us-east-2
role-to-assume: ${{ secrets.DATASTORE_E2E_ROLE_ARN }}
- name: Create temp AWS profile
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \
aws configure set aws_session_token $AWS_SESSION_TOKEN && \
aws configure set default.region $AWS_REGION
- name: Pull down Datastore AWS environments
run: yarn environments datastore pull
- name: Configure liveness credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 https://github.com/aws-actions/configure-aws-credentials/commit/e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
with:
aws-region: us-east-2
role-to-assume: ${{ secrets.LIVENESS_E2E_ROLE_ARN }}
- name: Create temp AWS profile
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \
aws configure set aws_session_token $AWS_SESSION_TOKEN && \
aws configure set default.region $AWS_REGION
- name: Pull down Liveness AWS environments
run: yarn environments liveness pull
- name: Configure in-app-messaging credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 https://github.com/aws-actions/configure-aws-credentials/commit/e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
with:
aws-region: us-east-2
role-to-assume: ${{ secrets.IN_APP_MESSAGING_E2E_ROLE_ARN }}
# Amplify CLI does not support headless pull with temporary credentials
# when useProfile is false.
# See: https://github.com/aws-amplify/amplify-cli/issues/11009.
- name: Create temp AWS Profile
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \
aws configure set aws_session_token $AWS_SESSION_TOKEN && \
aws configure set default.region $AWS_REGION
- name: Pull down In-app-messaging AWS environments
run: yarn environments in-app-messaging pull
- name: Delete AWS profile
run: rm -rf ~/.aws
- name: Build ${{ matrix.example }} example
run: yarn ${{ matrix.example }}-example build
- name: Start ${{ matrix.example }} example
run: yarn ${{ matrix.example }}-example start & npx wait-on -c waitOnConfig.json -t 20000 http-get://localhost:3000/ui/components/authenticator/sign-in-with-username
env:
# Setting this value temporarily since the beta liveness sample app hits the gamma endpoint
NEXT_PUBLIC_STREAMING_API_URL: wss://streaming-rekognition-gamma.us-east-1.amazonaws.com
- name: Run E2E tests against ${{ matrix.example }} example
id: e2e
run: yarn e2e test:examples
env:
# Override on the default value in `cypress.json` with framework-specific tag
TAGS: '${{ matrix.tags }}'
# Env values for testing flows
DOMAIN: ${{ secrets.DOMAIN }}
PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }}
USERNAME: ${{ secrets.USERNAME }}
NEW_PASSWORD: ${{ secrets.NEW_PASSWORD }}
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }}
- name: Upload failure screenshots and errors
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce
if: ${{ failure() && steps.e2e.outcome != 'success' }}
with:
name: e2e-cypress-error-${{ matrix.package }}
path: |
packages/e2e/cypress/videos/**
packages/e2e/cypress/screenshots/**
retention-days: 5
check-changed-packages:
runs-on: ubuntu-latest
outputs:
has-changed-packages: ${{ steps.has-rn-changed-packages.outputs.has-changed-packages }}
steps:
- name: Checkout Amplify UI
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
ref: ${{ inputs.commit }}
repository: ${{ inputs.repository }}
fetch-depth: 2
persist-credentials: false
- name: Determine if there were changes to react-native packages
if: ${{ inputs.skip-changed-packages-check == 'false' }}
id: has-rn-changed-packages
uses: ./.github/actions/changed-packages
with:
commit: ${{ inputs.commit }}
packages: |
packages/react-native
packages/react-core
packages/react-core-notifications
packages/ui
packages/e2e
e2e-ios:
needs: check-changed-packages
if: ${{ inputs.skip-changed-packages-check == 'true' || needs.check-changed-packages.outputs.has-changed-packages == 'true' }}
runs-on: macos-12
environment: ci
env:
NODE_ENV: test
steps:
- name: Checkout Amplify UI
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
ref: ${{ inputs.commit }}
repository: ${{ inputs.repository }}
persist-credentials: false
- name: Setup Node.js 16
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 https://github.com/actions/setup-node/commit/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version: 16
cache: 'yarn'
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
- name: Restore CocoaPods cache
id: restore-cocoapods-cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ./examples/react-native/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ inputs.commit }}
restore-keys: |
pods-${{ hashFiles('examples/react-native/ios/Podfile.lock') }}
pods-
continue-on-error: true
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Install simulator
run: |
brew tap wix/brew
brew install applesimutils
- name: Install packages
uses: ./.github/actions/install-with-retries
with:
skip-cypress-binary: true
- name: Build @aws-amplify/ui package
run: yarn ui build
- name: Build react-core package
run: yarn react-core build
- name: Build react-core-notifications package
run: yarn react-core-notifications build
- name: Build react-native package
run: yarn react-native build
- name: Update CocoaPods
run: |
gem update cocoapods xcodeproj
yarn react-native-example ios:pod-install
- name: Add Amplify CLI
run: yarn global add @aws-amplify/cli
- name: Get CLI versions
id: cli-version
run: echo "version=$(amplify --version)" >> $GITHUB_OUTPUT
- name: Configure auth credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 https://github.com/aws-actions/configure-aws-credentials/commit/e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
with:
aws-region: us-east-2
role-to-assume: ${{ secrets.AUTH_E2E_ROLE_ARN }}
# Amplify CLI does not support headless pull with temporary credentials
# when useProfile is false.
# See: https://github.com/aws-amplify/amplify-cli/issues/11009.
- name: Create temp AWS Profile
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \
aws configure set aws_session_token $AWS_SESSION_TOKEN && \
aws configure set default.region $AWS_REGION
- name: Pull down Auth AWS environments
run: yarn environments auth pull
- name: Delete AWS profile
run: rm -rf ~/.aws
- name: Start Metro Bundler in background
run: yarn react-native-example dev --reset-cache &
- name: Rebuild detox cache
run: yarn detox rebuild-framework-cache
- name: Build ios example
run: yarn e2e detox:build:ios:debug
- name: Run E2E tests against react-native example
run: yarn e2e detox:e2e:ios:debug --retry 1 --fail-fast
env:
# Env values for testing flows
DOMAIN: ${{ secrets.DOMAIN }}
PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }}
USERNAME: ${{ secrets.USERNAME }}
NEW_PASSWORD: ${{ secrets.NEW_PASSWORD }}
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }}
- name: Upload failure screenshots and errors
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce
if: ${{ failure() && steps.e2e-ios.outcome != 'success' }}
with:
name: e2e-detox-error-react-native-ios
path: |
packages/e2e/detox/screenshots/**
retention-days: 5
e2e-android:
needs: check-changed-packages
if: ${{ inputs.skip-changed-packages-check == 'true' || needs.check-changed-packages.outputs.has-changed-packages == 'true' }}
runs-on: macos-12
environment: ci
env:
NODE_ENV: test
EMULATOR1_PORT: 5554
EMULATOR2_PORT: 5556
steps:
- name: Checkout Amplify UI
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
# For `pull_request_target`, we want ref to point to `pull_request.head.ref` because `github.ref`
# always points to the target branch.
# See: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
ref: ${{ inputs.commit }}
repository: ${{ inputs.repository }}
persist-credentials: false
- name: Install Java 11
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # 3.6.0
with:
distribution: 'corretto' # Amazon Corretto Build of OpenJDK
java-version: '11'
- name: Setup Node.js 16
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 https://github.com/actions/setup-node/commit/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version: 16
cache: 'yarn'
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
- name: Install packages
uses: ./.github/actions/install-with-retries
with:
skip-cypress-binary: true
- name: Build @aws-amplify/ui package
run: yarn ui build
- name: Build react-core package
run: yarn react-core build
- name: Build react-core-notifications package
run: yarn react-core-notifications build
- name: Build react-native package
run: yarn react-native build
- name: Add Amplify CLI
run: yarn global add @aws-amplify/cli
- name: Get CLI versions
id: cli-version
run: echo "version=$(amplify --version)" >> $GITHUB_OUTPUT
- name: Configure auth credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0 https://github.com/aws-actions/configure-aws-credentials/commit/e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
with:
aws-region: us-east-2
role-to-assume: ${{ secrets.AUTH_E2E_ROLE_ARN }}
# Amplify CLI does not support headless pull with temporary credentials
# when useProfile is false.
# See: https://github.com/aws-amplify/amplify-cli/issues/11009.
- name: Create temp AWS Profile
run: |
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID && \
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY && \
aws configure set aws_session_token $AWS_SESSION_TOKEN && \
aws configure set default.region $AWS_REGION
- name: Pull down Auth AWS environments
run: yarn environments auth pull
- name: Delete AWS profile
run: rm -rf ~/.aws
- name: Install emulator
run: |
brew install coreutils
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'build-tools;33.0.2' platform-tools 'platforms;android-27'
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "system-images;android-27;default;x86_64"
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd --force --name Pixel_5_API_27 --device "pixel_5" --abi x86_64 --package "system-images;android-27;default;x86_64"
printf 'hw.ramSize=2048\n' >> ~/.android/avd/Pixel_5_API_27.avd/config.ini
printf 'hw.heapSize=576\n' >> ~/.android/avd/Pixel_5_API_27.avd/config.ini
- name: Start Android emulator
run: |
function configure_emulator() {
local port=$1
nohup $ANDROID_HOME/emulator/emulator -avd Pixel_5_API_27 -port "$port" -read-only -no-window -no-boot-anim -no-audio -gpu host -accel on &
timeout 5m $ANDROID_HOME/platform-tools/adb -s "emulator-$port" wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
$ANDROID_HOME/platform-tools/adb -s "emulator-$port" shell settings put secure spell_checker_enabled 0
$ANDROID_HOME/platform-tools/adb -s "emulator-$port" shell settings put global window_animation_scale 0.0
$ANDROID_HOME/platform-tools/adb -s "emulator-$port" shell settings put global transition_animation_scale 0.0
$ANDROID_HOME/platform-tools/adb -s "emulator-$port" shell settings put global animator_duration_scale 0.0
}
configure_emulator $EMULATOR1_PORT
configure_emulator $EMULATOR2_PORT
$ANDROID_HOME/platform-tools/adb devices
- name: Start Metro Bundler in background
run: yarn react-native-example dev --reset-cache &
- name: Build android example
run: yarn e2e detox:build:android:debug
- name: Run E2E tests against react-native example
run: |
DETOX_HEADLESS=true yarn e2e detox:e2e:android:debug --retry 1 --fail-fast --parallel 2
env:
# Env values for testing flows
DOMAIN: ${{ secrets.DOMAIN }}
PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }}
USERNAME: ${{ secrets.USERNAME }}
NEW_PASSWORD: ${{ secrets.NEW_PASSWORD }}
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }}
- name: Terminate emulators
if: success() || failure()
run: |
adb -s emulator-$EMULATOR1_PORT emu kill
adb -s emulator-$EMULATOR2_PORT emu kill
- name: Upload failure screenshots and errors
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce
if: ${{ failure() && steps.e2e-android.outcome != 'success' }}
with:
name: e2e-detox-error-react-native-android
path: |
packages/e2e/detox/screenshots/**
retention-days: 5
docs:
runs-on: ubuntu-latest
environment: ci
env:
NODE_ENV: test
steps:
- name: Checkout Amplify UI
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
ref: ${{ inputs.commit }}
repository: ${{ inputs.repository }}
persist-credentials: false
- name: Setup Node.js 16
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 https://github.com/actions/setup-node/commit/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version: 16
cache: 'yarn'
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
- name: Restore cypress runner Cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: restore-cypress-cache
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Restore Puppeteer runner cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: restore-puppeteer-cache
with:
path: ~/.cache/puppeteer
key: ${{ runner.os }}-puppeteer-${{ hashFiles('yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Restore node_modules cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
id: restore-cache
with:
path: |
./node_modules
**/node_modules
key: ${{ runner.os }}-nodemodules-${{ inputs.commit }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
- name: Install packages
if: steps.restore-cache.outputs.cache-hit != 'true' || steps.restore-puppeteer-cache.outputs.cache-hit != 'true' || steps.restore-cypress-cache.outputs.cache-hit != 'true'
uses: ./.github/actions/install-with-retries
with:
skip-cypress-binary: false
- name: Build ui package
run: yarn ui build
- name: Build react-core package
run: yarn react-core build
- name: Build react-core-notifications package
run: yarn react-core-notifications build
- name: Build react package
run: yarn react build
- name: Build react-notifications package
run: yarn react-notifications build
- name: Build react-geo package
run: yarn react-geo build
- name: Build react-storage package
run: yarn react-storage build
- name: Build react-liveness package
run: yarn react-liveness build
- name: Build docs package
run: yarn docs build
env:
SITE_URL: ${{ secrets.SITE_URL }}
DOCSEARCH_DOCS_APP_ID: ${{ secrets.DOCSEARCH_DOCS_APP_ID }}
DOCSEARCH_DOCS_API_KEY: ${{ secrets.DOCSEARCH_DOCS_API_KEY }}
DOCSEARCH_DOCS_INDEX_NAME: ${{ secrets.DOCSEARCH_DOCS_INDEX_NAME }}
- name: Start docs site
run: yarn docs start & npx wait-on -c waitOnConfig.json -t 20000 http-get://localhost:3000
- name: Run E2E tests against docs
run: yarn e2e test:theme
id: e2e
env:
# Env values for testing flows
DOMAIN: ${{ secrets.DOMAIN }}
PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }}
USERNAME: ${{ secrets.USERNAME }}
NEW_PASSWORD: ${{ secrets.NEW_PASSWORD }}
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }}
- name: Run Docs link checker
run: yarn docs test:links
- name: Upload failure screenshots and errors
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce
if: ${{ failure() && steps.e2e.outcome != 'success' }}
with:
name: docs-e2e-cypress-error
path: |
packages/e2e/cypress/videos/**
packages/e2e/cypress/screenshots/**
retention-days: 5