-
Notifications
You must be signed in to change notification settings - Fork 299
164 lines (158 loc) · 7.04 KB
/
build-and-runtime-test.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
# Description: this workflow runs build and simple runtime tests on supported
# frameworks and their build systems.
#
# Triggered by: it runs every 15 minutes.
name: Build and Runtime Test
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
on:
schedule:
- cron: '*/15 * * * *' # Run every 15 minutes
jobs:
build:
runs-on: ubuntu-latest
environment: ci
strategy:
fail-fast: false
matrix:
# Paths for each example app we want to test build on
include:
- framework: angular
build-tool: angularcli
- framework: react
build-tool: cra
- framework: react
build-tool: cra-ts
- framework: react
build-tool: next
- framework: react
build-tool: vite
- framework: react
build-tool: vite3
- framework: vue
build-tool: vite
- framework: vue
build-tool: vite3
- framework: vue
build-tool: vuecli
steps:
- name: Checkout Amplify UI
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
with:
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: Install canary package
uses: ./.github/actions/install-with-retries
with:
no-lockfile: true
working-directory: ./canary/apps/${{ matrix.framework }}/${{ matrix.build-tool }}
- name: Add Amplify CLI
run: yarn global add @aws-amplify/cli
- 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.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 AWS environments
run: yarn pull
working-directory: ./canary
- name: Delete AWS Profile
run: rm -rf ~/.aws
- name: Build example app
run: yarn build
working-directory: ./canary/apps/${{ matrix.framework }}/${{ matrix.build-tool }}
# This steps attempts to restore cypress runner. It will not create any new
# cache entries however, because cypress runner isn't available yet.
- name: Restore cypress runner from 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 }}-canary-cypress-${{ hashFiles('canary/e2e/yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Install e2e packages
uses: ./.github/actions/install-with-retries
with:
working-directory: ./canary/e2e
# If we got a cache hit on cypress runner, then we will skip cypress binary
# installation. Otherwise, it will install cypress binary.
skip-cypress-binary: ${{ steps.restore-cypress-cache.outputs.cache-hit }}
# If cypress cache was missed, then we need to create new cache entry and upload it.
# At this point, cypress runner should've been installed from the previous installation
# step, so we go ahead and update the cache entry.
- name: Cache cypress runner
if: steps.restore-cypress-cache.outputs.cache-hit != 'true'
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 https://github.com/actions/cache/commit/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-canary-cypress-${{ hashFiles('canary/e2e/yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Start ${{ matrix.framework }}/${{ matrix.build-tool }} example
run: yarn start & npx wait-on -c waitOnConfig.json -t 20000 http-get://localhost:3000
working-directory: ./canary/apps/${{ matrix.framework }}/${{ matrix.build-tool }}
- name: Run E2E tests against ${{ matrix.framework }}/${{ matrix.build-tool }} example
run: yarn test
id: e2e
working-directory: ./canary
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 videos and screenshots
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 https://github.com/actions/upload-artifact/commit/0b7f8abb1508181956e8e162db84b466c27e18ce
if: ${{ failure() && steps.e2e.outcome != 'success' }}
with:
name: canary-cypress-error-${{ matrix.framework }}-${{ matrix.build-tool }}
path: |
canary/e2e/cypress/videos/**
canary/e2e/cypress/screenshots/**
retention-days: 5
log-failure-metric:
# Send a failure data point to metric BuildAndRuntimeTestFailure in github-workflows@ us-east-2, if it's a failure
runs-on: ubuntu-latest
environment: ci
needs: build
if: ${{ failure() }}
steps:
- name: Log failure data point to metric BuildAndRuntimeTestFailure
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main
with:
metric-name: BuildAndRuntimeTestFailure
value: 1
role-to-assume: ${{ secrets.METRIC_LOGGER_ROLE_ARN }}
aws-region: us-east-2
log-success-metric:
# Send a success data point to metric BuildAndRuntimeTestFailure in github-workflows@ us-east-2, if it's a success
runs-on: ubuntu-latest
environment: ci
needs: build
if: ${{ success() }}
steps:
- name: Log success data point to metric BuildAndRuntimeTestFailure
uses: aws-amplify/amplify-ui/.github/actions/log-metric@main
with:
metric-name: BuildAndRuntimeTestFailure
value: 0
role-to-assume: ${{ secrets.METRIC_LOGGER_ROLE_ARN }}
aws-region: us-east-2