-
Notifications
You must be signed in to change notification settings - Fork 1.8k
333 lines (316 loc) · 11 KB
/
ci.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
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
merge_group:
types: [checks_requested]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
dedupe:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js 20.x
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '20.x'
- name: Run yarn dedupe
run: yarn dedupe --check
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js 20.x
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '20.x'
- name: Install dependencies
env:
YARN_ENABLE_HARDENED_MODE: 0
run: yarn install --immutable --immutable-cache
- name: Check formatting of project files
run: yarn format:diff
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js 20.x
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '20.x'
- name: Install dependencies
env:
YARN_ENABLE_HARDENED_MODE: 0
run: yarn install --immutable --immutable-cache
- name: Lint JavaScript files
run: yarn lint
- name: Lint Sass files
run: yarn lint:styles
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js 20.x
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '20.x'
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
if: github.event_name != 'merge_group'
id: cache
with:
path: |
node_modules
*/**/node_modules
key:
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
'packages/**/yarn.lock') }}
- name: Install dependencies
env:
YARN_ENABLE_HARDENED_MODE: 0
run: yarn install --immutable --immutable-cache
- name: Build project
run: yarn build
- name: Check generated styles
run: |
yarn carbon-cli check --ignore '**/@(node_modules|examples|components|react|fixtures|compat)/**' 'packages/**/*.scss'
- name: Run tests
run: yarn test --ci --collectCoverage
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
e2e:
name: 'test:e2e'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js 20.x
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '20.x'
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
if: github.event_name != 'merge_group'
id: cache
with:
path: |
node_modules
*/**/node_modules
key:
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
'packages/**/yarn.lock') }}
- name: Install dependencies
env:
YARN_ENABLE_HARDENED_MODE: 0
run: yarn install --immutable --immutable-cache
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
e2e:
- 'e2e/**'
- 'packages/icons/**'
- 'packages/icons-react/**'
- 'packages/icons-vue/**'
- 'packages/pictograms/**'
- 'packages/pictograms-react/**'
- 'packages/icon-build-helpers/**'
- name: Build project
if: ${{ steps.filter.outputs.e2e == 'true' }}
run: yarn build
- name: Run e2e tests
if: ${{ steps.filter.outputs.e2e == 'true' }}
run: yarn test:e2e
vrt-runner:
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js 20.x
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '20.x'
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
if: github.event_name != 'merge_group'
id: cache
with:
path: |
node_modules
*/**/node_modules
key:
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
'packages/**/yarn.lock') }}
- name: Install dependencies
env:
YARN_ENABLE_HARDENED_MODE: 0
run: yarn install --immutable --immutable-cache
- name: Install browsers
run: yarn playwright install --with-deps
- name: Build project
run: yarn build
- name: Build storybook
run: yarn workspace @carbon/react storybook:build
- name: Run storybook
id: storybook
run: |
npx serve -l 3000 packages/react/storybook-static &
pid=$!
echo "pid=$pid" >> $GITHUB_OUTPUT
- uses: ./actions/wait-for-it
with:
URL: 'http://localhost:3000'
timeout-minutes: 3
- name: Run VRT
if: github.repository == 'carbon-design-system/carbon'
env:
PERCY_TOKEN: c9a21a3fde4fda0a0f822d633426ab26e2ab2c1cba55221d342d4047744c8c24
PERCY_PARALLEL_TOTAL: 4
run: |
yarn percy exec --parallel -- yarn playwright test --project chromium --grep @vrt --shard="${{ matrix.shardIndex }}/${{ matrix.shardTotal }}"
- name: Stop storybook
run: kill ${{ steps.storybook.outputs.pid }}
- name: Upload blob report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a #4.3.6
with:
name: playwright-vrt-blob-report-${{ matrix.shardIndex }}
path: blob-report
retention-days: 1
vrt:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: vrt-runner
steps:
- name: Check VRT Runner job status
if: ${{ needs.vrt-runner.result != 'success' }}
run: exit 1
avt-runner:
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js 20.x
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '20.x'
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
if: github.event_name != 'merge_group'
id: cache
with:
path: |
node_modules
*/**/node_modules
key:
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
'packages/**/yarn.lock') }}
- name: Install dependencies
env:
YARN_ENABLE_HARDENED_MODE: 0
run: yarn install --immutable --immutable-cache
- name: Install browsers
run: yarn playwright install --with-deps
- name: Build project
run: yarn build
- name: Build storybook
run: yarn workspace @carbon/react storybook:build
- name: Run storybook
id: storybook
run: |
npx serve -l 3000 packages/react/storybook-static &
pid=$!
echo "pid=$pid" >> $GITHUB_OUTPUT
- uses: ./actions/wait-for-it
with:
URL: 'http://localhost:3000'
timeout-minutes: 3
- name: Run AVT
if: github.repository == 'carbon-design-system/carbon'
run: |
yarn playwright test --project chromium --grep @avt --shard="${{ matrix.shardIndex }}/${{ matrix.shardTotal }}"
- name: Stop storybook
run: kill ${{ steps.storybook.outputs.pid }}
- name: Upload blob report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a #4.3.6
with:
name: playwright-avt-blob-report-${{ matrix.shardIndex }}
path: blob-report
retention-days: 1
avt:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: avt-runner
steps:
- name: Check AVT Runner job status
if: ${{ needs.avt-runner.result != 'success' }}
run: exit 1
merge-playwright-reports:
# Merge reports after *-runner jobs, even if some shards have failed
if: ${{ !cancelled() }}
needs: [vrt-runner, avt-runner]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js 20.x
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '20.x'
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
if: github.event_name != 'merge_group'
id: cache
with:
path: |
node_modules
*/**/node_modules
key:
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock',
'packages/**/yarn.lock') }}
- name: Install dependencies
env:
YARN_ENABLE_HARDENED_MODE: 0
run: yarn install --immutable --immutable-cache
- name: Download vrt blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-playwright-vrt-blob-reports
pattern: playwright-vrt-blob-report-*
merge-multiple: true
- name: Merge vrt reports into HTML Report
run:
npx playwright merge-reports --reporter html
./all-playwright-vrt-blob-reports
- name: Upload vrt HTML report
uses: actions/upload-artifact@v4
with:
name: html-playwright-vrt-report--attempt-${{ github.run_attempt }}
path: playwright-vrt-report
retention-days: 14
- name: Download avt blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-playwright-avt-blob-reports
pattern: playwright-avt-blob-report-*
merge-multiple: true
- name: Merge avt reports into HTML Report
run:
npx playwright merge-reports --reporter html
./all-playwright-avt-blob-reports
- name: Upload avt HTML report
uses: actions/upload-artifact@v4
with:
name: html-playwright-avt-report--attempt-${{ github.run_attempt }}
path: playwright-avt-report
retention-days: 14