-
Notifications
You must be signed in to change notification settings - Fork 305
178 lines (173 loc) · 7.44 KB
/
reusable-build-system-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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Description: this is a reusable workflow that runs build on mega-apps that have all the connected components for React Native.
#
# See build-system-test.yml for usage.
on:
workflow_call:
inputs:
dist-tag:
required: true
type: string
secrets:
AUTH_E2E_ROLE_ARN:
required: true
DOMAIN:
required: true
PHONE_NUMBER:
required: true
USERNAME:
required: true
NEW_PASSWORD:
required: true
VALID_PASSWORD:
required: true
jobs:
build:
runs-on: ubuntu-latest
environment: ci
strategy:
fail-fast: false
matrix:
framework: [react]
# temporarily pointing all react tests to v18
# framework-version: [latest]
framework-version: [18]
build-tool: [next, vite]
build-tool-version: [latest]
pkg-manager: [npm]
node-version: [20]
pkg-manager-version: [latest]
include:
- framework: react
framework-version: 18
build-tool: next
build-tool-version: 13
pkg-manager: npm
node-version: 20
- framework: react
framework-version: 18
build-tool: vite
build-tool-version: 3
pkg-manager: npm
node-version: 20
- framework: angular
framework-version: latest
build-tool: angular-cli
build-tool-version: latest
pkg-manager: npm
node-version: 20
- framework: angular
framework-version: 14
build-tool: angular-cli
build-tool-version: 14
pkg-manager: npm
node-version: 20
- framework: vue
framework-version: 3 # here use "3" instead of "latest" because .vuerc(preset) doesn't accept "latest" as "vueVersion"
build-tool: vue-cli
build-tool-version: latest
pkg-manager: yarn # vue-cli defualt pkg-manager is yarn. It can't be customized in the preset.json.
node-version: 20
- framework: vue
framework-version: latest
build-tool: vite
build-tool-version: latest
pkg-manager: npm
node-version: 20
- framework: vue
framework-version: 3
build-tool: vite
build-tool-version: 3
pkg-manager: npm
node-version: 20
- framework: vue
framework-version: latest
build-tool: nuxt
build-tool-version: latest
pkg-manager: npm
node-version: 20
env:
MEGA_APP_NAME: ${{matrix.framework}}-${{ matrix.framework-version }}-${{ matrix.build-tool }}-${{ matrix.build-tool-version }}-ui-${{ inputs.dist-tag }}
steps:
- name: Checkout Amplify UI
uses: actions/checkout@b80ff79f1755d06ba70441c368a6fe801f5f3a62 # v4.1.3 https://github.com/actions/checkout/commit/cd7d8d697e10461458bc61a30d094dc601a8b017
with:
persist-credentials: false
- name: Setup Node.js ${{ matrix.node-version }} with ${{ matrix.pkg-manager }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 https://github.com/actions/setup-node/commit/60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: ${{ matrix.node-version }}
cache: ${{ matrix.pkg-manager }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
- name: Add Amplify CLI
run: yarn global add @aws-amplify/cli
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 https://github.com/aws-actions/configure-aws-credentials/commit/e3dd6a429d7300a6a4c196c26e071d42e0343502
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: npm run pull
working-directory: build-system-tests
- name: Delete AWS Profile
run: rm -rf ~/.aws
- name: Restore cypress runner from Cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
id: restore-cypress-cache
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-canary-cypress-${{ hashFiles('build-system-tests/e2e/yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Create MegaApp ${{ env.MEGA_APP_NAME }} and run build on NodeJS ${{ matrix.node-version }}
run: npm run setup:${{ matrix.framework }}:${{matrix.build-tool}} -- --framework-version ${{matrix.framework-version}} --build-tool-version ${{matrix.build-tool-version}} --pkg-manager ${{matrix.pkg-manager}} --tag ${{inputs.dist-tag}}
shell: bash
working-directory: build-system-tests
- name: Install e2e packages
uses: ./.github/actions/install-with-retries
with:
working-directory: build-system-tests/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@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-canary-cypress-${{ hashFiles('build-system-tests/e2e/yarn.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Run E2E tests against ${{ env.MEGA_APP_NAME }} example
run: npm run test:web
id: e2e
working-directory: build-system-tests
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 }}
TAGS: '@${{ matrix.framework }}'
- name: Upload videos and screenshots
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.5.0 https://github.com/actions/upload-artifact/commit/65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
if: ${{ failure() && steps.e2e.outcome != 'success' }}
with:
name: canary-cypress-error-${{ env.MEGA_APP_NAME }}
path: |
build-system-tests/e2e/cypress/videos/**
build-system-test/e2e/cypress/screenshots/**
retention-days: 5