-
Notifications
You must be signed in to change notification settings - Fork 38
317 lines (307 loc) · 10.9 KB
/
build.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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Fozzie Components CI
on:
pull_request:
types: [assigned, opened, synchronize, reopened]
paths-ignore:
- ".husky/**"
- "stories/**"
- ".vscode/**"
- "README.md"
- "CONTRIBUTING.md"
- "CHANGELOG.md"
- "LICENSE"
push:
branches:
- master
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
install:
runs-on: ubuntu-latest
steps:
# Checkout the Repo.
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
# Setup Node 20.
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
# Restore node_modules if cache exists. If not, cache is created at end of build.
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: node-modules-${{ hashFiles('**/yarn.lock') }}
# Run 'yarn' if cache doesn't exist. Use yarn add --cached to download packages from yarn cache folder where possible.
- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn add --cached
danger:
if: ${{ github.ref != 'refs/heads/master' }}
needs: install
runs-on: ubuntu-latest
steps:
# Checkout the Repo.
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
# Setup Node 20.
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
# Restore node_modules if cache exists. If not, cache is created at end of build.
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: node-modules-${{ hashFiles('**/yarn.lock') }}
# Run Danger Checks.
- name: Run Danger Checks
run: yarn danger ci --failOnErrors
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
build:
needs: install
runs-on: ubuntu-latest
steps:
# Checkout the Repo.
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup Node 20.
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
# Restore node_modules - Cache should exist as one was created in previous 'install' job.
- name: Cache Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: node-modules-${{ hashFiles('**/yarn.lock') }}
# Build components. Only components with out-of-date Turborepo hash will rebuilt, speeding up build time.
- name: Build Components
run: yarn build
# Lint components
- name: Lint Components
run: yarn lint --concurrency=10
# Cache 'storybook-static'
- name: Cache Storybook Static Directory
id: storybook-cache
uses: actions/cache@v4
with:
path: ./packages/storybook/storybook-static
key: storybook-cache-${{ github.ref_name }}-${{ github.run_id }}
# Build Storybook
- name: Build Storybook (All Components)
run: yarn storybook:build
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
unit-tests:
strategy:
fail-fast: false
matrix:
component-type:
[
"atoms",
"molecules",
"organisms",
"pages",
"templates",
"tools",
"services",
]
name: unit-tests-${{ matrix.component-type }}
needs: build
runs-on: ubuntu-latest
steps:
# Checkout the Repo
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup Node 20
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
# Restore node_modules - Cache should exist as one was created in previous 'install' job
- name: Restore Cache - Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: node-modules-${{ hashFiles('**/yarn.lock') }}
# Build components. Only components with out-of-date Turborepo hash will rebuilt, speeding up build time.
- name: Build Components
run: yarn build
# Unit Tests
- name: Unit Test Components
run: yarn ci:test:${{ matrix.component-type}} --concurrency=10
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
browser-tests:
strategy:
fail-fast: false
matrix:
component-type: ["atoms", "molecules", "organisms", "pages"]
name: browser-tests-${{ matrix.component-type }}
needs: build
runs-on: ubuntu-latest
steps:
# Checkout the Repo
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup Node 20
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
# Restore node_modules - Cache should exist as one was created in previous 'install' job
- name: Restore Cache - Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: node-modules-${{ hashFiles('**/yarn.lock') }}
# Build Components
- name: Build Components
run: yarn build
# Restore Storybook 'storybook-static'
- name: Cache Storybook Static Directory
id: storybook-cache
uses: actions/cache@v4
with:
path: ./packages/storybook/storybook-static
key: storybook-cache-${{ github.ref_name }}-${{ github.run_id }}
- name: Run Component / A11y / Visual Tests
run: |
FILTER_FLAG=""
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.ref }}" != "refs/heads/master" ]]; then
FILTER_FLAG="--filter=...[origin/master]"
fi
yarn storybook:serve-static &
yarn ci:test-component:chrome:${{ matrix.component-type }} --concurrency=1 $FILTER_FLAG &&
yarn ci:test-a11y:chrome:${{ matrix.component-type }} --concurrency=1 $FILTER_FLAG &&
yarn ci:test:visual:${{ matrix.component-type }} --concurrency=1 $FILTER_FLAG
# On Failure - Upload Allure Report
- name: Generate Allure Report
if: failure()
run: yarn allure:generate
- name: Upload Allure Report
if: failure()
uses: actions/upload-artifact@v3
with:
name: test-artifacts-${{ matrix.component-type }}
path: |
allure-report
test/results/axe-violations
env:
PERCY_TOKEN_F_BUTTON: ${{ secrets.PERCY_TOKEN_F_BUTTON }}
PERCY_TOKEN_F_FORM_FIELD: ${{ secrets.PERCY_TOKEN_F_FORM_FIELD }}
PERCY_TOKEN_F_ALERT: ${{ secrets.PERCY_TOKEN_F_ALERT }}
PERCY_TOKEN_F_CARD_WITH_CONTENT: ${{ secrets.PERCY_TOKEN_F_CARD_WITH_CONTENT }}
PERCY_TOKEN_F_MEGA_MODAL: ${{ secrets.PERCY_TOKEN_F_MEGA_MODAL }}
PERCY_TOKEN_F_COOKIE_BANNER: ${{ secrets.PERCY_TOKEN_F_COOKIE_BANNER }}
PERCY_TOKEN_F_FOOTER: ${{ secrets.PERCY_TOKEN_F_FOOTER }}
PERCY_TOKEN_F_HEADER: ${{ secrets.PERCY_TOKEN_F_HEADER }}
PERCY_TOKEN_F_STATUS_BANNER: ${{ secrets.PERCY_TOKEN_F_STATUS_BANNER }}
PERCY_TOKEN_F_ACCOUNT_INFO: ${{ secrets.PERCY_TOKEN_F_ACCOUNT_INFO }}
PERCY_TOKEN_F_CHECKOUT: ${{ secrets.PERCY_TOKEN_F_CHECKOUT }}
PERCY_TOKEN_F_CONTACT_PREFERENCES: ${{ secrets.PERCY_TOKEN_F_CONTACT_PREFERENCES }}
PERCY_TOKEN_F_MFA: ${{ secrets.PERCY_TOKEN_F_MFA }}
PERCY_TOKEN_F_REGISTRATION: ${{ secrets.PERCY_TOKEN_F_REGISTRATION }}
PERCY_TOKEN_F_TAKEAWAYPAY_ACTIVATION: ${{ secrets.PERCY_TOKEN_F_TAKEAWAYPAY_ACTIVATION }}
PERCY_TOKEN_F_RATING: ${{ secrets.PERCY_TOKEN_F_RATING }}
PERCY_TOKEN_F_SEGMENTED_CONTROL: ${{ secrets.PERCY_TOKEN_F_SEGMENTED_CONTROL }}
PERCY_TOKEN_F_TOGGLE_SWITCH: ${{ secrets.PERCY_TOKEN_F_TOGGLE_SWITCH }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
storybook-deploy:
if: ${{ github.ref == 'refs/heads/master' }}
needs: build
runs-on: ubuntu-latest
steps:
# Checkout the Repo.
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup Node 20
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
# Restore node_modules - Cache should exist as one was created in previous 'install' job.
- name: Restore Cache - Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: node-modules-${{ hashFiles('**/yarn.lock') }}
# Run 'yarn' if cache doesn't exist. Use yarn add --cached to download packages from yarn cache folder where possible.
- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn add --cached
# Restore Storybook 'storybook-static'.
- name: Cache Storybook Static Directory
id: storybook-cache
uses: actions/cache@v4
with:
path: ./packages/storybook/storybook-static
key: storybook-cache-${{ github.ref_name }}-${{ github.run_id }}
# Deploy Storybook.
- name: Storybook deploy
run: yarn storybook:deploy
env:
GH_TOKEN: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
publish:
needs: browser-tests
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
# Checkout the Repo.
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup Node 20
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
# Restore node_modules - Cache should exist as one was created in previous 'install' job.
- name: Restore Cache - Node Modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: "**/node_modules"
key: node-modules-${{ hashFiles('**/yarn.lock') }}
- run: yarn build
- name: Auth with NPM
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
- name: Publish unreleased package versions to npm
run: yarn lerna publish from-package --ignore-scripts --yes --no-verify-access
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}