-
Notifications
You must be signed in to change notification settings - Fork 10
368 lines (327 loc) · 11.2 KB
/
code-standards.yaml
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
name: code standards
on:
pull_request:
merge_group:
jobs:
should-test:
name: check if we should run tests
runs-on: ubuntu-latest
outputs:
"no": ${{ steps.skip-tests.outputs.no }}
"yes": ${{ steps.skip-tests.outputs.yes }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: list files that have changed from main
id: diff
run: echo "diff=$(git diff --name-only origin/main)" | tr "\n" "\t" >> $GITHUB_OUTPUT
- name: determine whether to skip tests
id: skip-tests
uses: actions/github-script@v7
with:
script: |
// The paths that are exempt from testing. If all of the changed
// files are in these paths, we can skip tests completely.
const exemptPaths = [
"docs/",
"scripts/",
".bp-config/",
];
// Get the list of changed files from the previous step and turn it
// into something we can work with.
const changedFiles = ${{ toJSON(steps.diff.outputs.diff) }}
.split("\t")
.filter(value => value.length > 0);
// Determine whether to skip tests. We will skip tests if it is true
// for EVERY FILE that they are in ANY of the exempted paths.
const skipTests = changedFiles.every(file => exemptPaths.some(path => file.startsWith(path)));
// Set the output so other jobs can use it. If we are skipping
// tests, add an annotation so we know, and list out the files that
// were changed. This may be helpful for debugging if things go
// sideways later on.
core.setOutput('no', skipTests);
core.setOutput('yes', !skipTests);
if(skipTests) {
core.notice(`Skipping tests. Modified files are:\n* ${changedFiles.join("\n* ")}`);
}
php-lint:
name: PHP lint
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: lint PHP
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/php-lint
js-lint:
name: JS lint
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: lint Javascript
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/javascript-lint
js-component-tests:
name: JS Component Tests
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: run Javascript component tests
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/javascript-component-tests
style-lint:
name: SCSS lint
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: lint styles
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/style-lint
interop-layer-unit-tests:
name: interop layer unit tests
runs-on: ubuntu-latest
needs: [should-test]
defaults:
run:
working-directory: ./api-interop-layer/
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup node
if: needs.should-test.outputs.yes == 'true'
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: install dependencies
if: needs.should-test.outputs.yes == 'true'
run: npm ci
- name: test
if: needs.should-test.outputs.yes == 'true'
run: npm test
- name: store coverage output
if: needs.should-test.outputs.yes == 'true'
uses: actions/upload-artifact@v4
with:
name: interop-coverage-report
path: ./api-interop-layer/coverage/clover.xml
retention-days: 1
- name: store coverage HTML
if: needs.should-test.outputs.yes == 'true'
uses: actions/upload-artifact@v4
with:
name: interop-coverage-html
path: ./api-interop-layer/coverage/
retention-days: 1
build-drupal-image:
name: build Drupal image
runs-on: ubuntu-latest
needs: [should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: build drupal
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/build-drupal-image
populate-database:
name: populate database
runs-on: ubuntu-latest
needs: [build-drupal-image, should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: populate database
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/populate-database
php-tests:
name: PHP tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup site
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/setup-site
- name: run unit tests
if: needs.should-test.outputs.yes == 'true'
run: |
curl http://localhost:8081/play/e2e
make backend-test
- name: store coverage output
if: needs.should-test.outputs.yes == 'true'
uses: actions/upload-artifact@v4
with:
name: drupal-coverage-report
path: .coverage/clover.xml
retention-days: 1
- name: store coverage HTML
if: needs.should-test.outputs.yes == 'true'
uses: actions/upload-artifact@v4
with:
name: drupal-coverage-html
# This is necessary because the action interprets this single entity
# starting with a dot as hidden. This is a bug in the action.
# https://github.com/actions/upload-artifact/issues/618
include-hidden-files: true
path: .coverage/
retention-days: 1
merge-code-coverage:
name: merge coverage
runs-on: ubuntu-latest
needs: [php-tests, interop-layer-unit-tests, should-test]
steps:
- name: get Drupal coverage output
if: needs.should-test.outputs.yes == 'true'
uses: actions/download-artifact@v4
with:
name: drupal-coverage-report
- name: rename
if: needs.should-test.outputs.yes == 'true'
run: mv clover.xml drupal.xml
- name: get interop layer coverage output
if: needs.should-test.outputs.yes == 'true'
uses: actions/download-artifact@v4
with:
name: interop-coverage-report
- name: rename
if: needs.should-test.outputs.yes == 'true'
run: mv clover.xml interop.xml
- name: setup PHP
if: needs.should-test.outputs.yes == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
extensions: uopz
- name: install combine library
if: needs.should-test.outputs.yes == 'true'
run: composer require kavinsky/clover-merge
- name: combine reports
if: needs.should-test.outputs.yes == 'true'
run: ./vendor/bin/clover-merge merge -o combined.xml drupal.xml interop.xml
- name: store coverage output
if: needs.should-test.outputs.yes == 'true'
uses: actions/upload-artifact@v4
with:
name: combined-coverage-report
path: combined.xml
retention-days: 1
min-code-coverage:
name: "90% code coverage"
runs-on: ubuntu-latest
needs: [merge-code-coverage, should-test]
steps:
- name: get combined coverage output
if: needs.should-test.outputs.yes == 'true'
uses: actions/download-artifact@v4
with:
name: combined-coverage-report
- name: 90% code coverage
if: needs.should-test.outputs.yes == 'true'
id: test-coverage
uses: johanvanhelden/gha-clover-test-coverage-check@v1
with:
percentage: 90
filename: combined.xml
metric: statements
accessibility-tests:
name: accessibility tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup site
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/setup-site
- name: run automated accessibility tests
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/accessibility-tests
browser-tests:
name: browser tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
steps:
- name: checkout
if: needs.should-test.outputs.yes == 'true'
uses: actions/checkout@v4
- name: setup site
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/setup-site
- name: run browser tests (Playwright)
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/browser-tests-playwright
merge-reports:
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ !cancelled() }} && needs.should-test.outputs.yes == 'true'
needs: [browser-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14
page-load-time-tests:
name: page load time tests
runs-on: ubuntu-latest
needs: [populate-database, should-test]
if: needs.should-test.outputs.yes == 'true'
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup site
if: needs.should-test.outputs.yes == 'true'
uses: ./.github/actions/setup-site
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: test load times
run: npx playwright test load-times
dependency-review:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: dependency review
uses: actions/dependency-review-action@v4