-
Notifications
You must be signed in to change notification settings - Fork 674
321 lines (273 loc) · 11.2 KB
/
Copy pathplaywright_tests.yml
File metadata and controls
321 lines (273 loc) · 11.2 KB
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
name: Playwright tests
concurrency:
group: wf-${{github.event.pull_request.number || github.sha}}-${{github.workflow}}
cancel-in-progress: true
on:
pull_request:
paths-ignore:
- 'apps/**/*.md'
merge_group:
workflow_dispatch:
env:
NX_SKIP_NX_CACHE: ${{ contains(github.event.pull_request.labels.*.name, 'skip-cache') && 'true' || 'false' }}
RUN_TESTS: true
jobs:
check-should-run:
name: Check if tests should run
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.check.outputs.should-run }}
styles-changed: ${{ steps.changes.outputs.styles }}
steps:
- uses: actions/checkout@v6
- name: Check RUN_TESTS flag
id: check
run: echo "should-run=${{ env.RUN_TESTS }}" >> $GITHUB_OUTPUT
- uses: dorny/paths-filter@v4
id: changes
with:
filters: |
styles:
- 'packages/devextreme-scss/scss/**'
- 'packages/devextreme-scss/icons/**'
- 'packages/devextreme-scss/images/**'
- 'packages/devextreme-scss/fonts/**'
- 'packages/devextreme/js/**/themes/**'
- 'e2e/playwright/helpers/accessibility/**'
build:
name: Build DevExtreme
needs: check-should-run
if: needs.check-should-run.outputs.should-run == 'true'
runs-on: devextreme-shr2
timeout-minutes: 15
steps:
- name: Get sources
uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.node-version'
- uses: pnpm/action-setup@v6
with:
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v5
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-cache
- uses: actions/cache@v5
name: Setup nx cache
with:
path: |
.nx/cache
.nx/workspace-data/*.db
.nx/workspace-data/*.db-wal
.nx/workspace-data/*.db-shm
key: ${{ runner.os }}-nx-v2-${{ github.workflow }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-nx-v2-${{ github.workflow }}-${{ github.job }}-${{ github.sha }}-
${{ runner.os }}-nx-v2-${{ github.workflow }}-${{ github.job }}-
${{ runner.os }}-nx-v2-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
shell: bash
env:
NODE_OPTIONS: --max-old-space-size=8192
run: |
pnpm exec nx build devextreme-scss
pnpm exec nx build devextreme -c testing
- name: Zip artifacts
working-directory: ./packages/devextreme
run: |
7z a -tzip -mx3 -mmt2 artifacts.zip artifacts ../devextreme-scss/scss/bundles
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: devextreme-artifacts-playwright
path: ./packages/devextreme/artifacts.zip
retention-days: 1
determine-playwright-matrix:
runs-on: ubuntu-latest
name: Determine Playwright matrix
needs: check-should-run
if: needs.check-should-run.outputs.should-run == 'true'
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Build matrix
id: matrix
run: |
base_matrix_start=$(cat <<'JSON'
[
{ "componentFolder": "accessibility", "name": "accessibility", "concurrency": 6 }
]
JSON
)
base_matrix_end=$(cat <<'JSON'
[
{ "componentFolder": "common", "name": "common", "concurrency": 3 },
{ "name": "generic", "theme": "generic.light", "concurrency": 2 },
{ "name": "material", "theme": "material.blue.light", "concurrency": 2 },
{ "name": "material - compact", "theme": "material.blue.light.compact", "concurrency": 2 },
{ "componentFolder": "cardView", "name": "cardView" },
{ "componentFolder": "dataGrid", "name": "dataGrid (1/4)", "indices": "1/4", "concurrency": 5 },
{ "componentFolder": "dataGrid", "name": "dataGrid (2/4)", "indices": "2/4", "concurrency": 5 },
{ "componentFolder": "dataGrid", "name": "dataGrid (3/4)", "indices": "3/4", "concurrency": 5 },
{ "componentFolder": "dataGrid", "name": "dataGrid (4/4)", "indices": "4/4", "concurrency": 5 },
{ "componentFolder": "editors", "name": "editors" },
{ "componentFolder": "navigation", "name": "navigation", "concurrency": 6 },
{ "componentFolder": "scheduler/common", "name": "scheduler / common (1/3)", "indices": "1/3", "concurrency": 6 },
{ "componentFolder": "scheduler/common", "name": "scheduler / common (2/3)", "indices": "2/3", "concurrency": 6 },
{ "componentFolder": "scheduler/common", "name": "scheduler / common (3/3)", "indices": "3/3", "concurrency": 6 },
{ "componentFolder": "scheduler/viewOffset", "name": "scheduler / viewOffset (1/2)", "indices": "1/2", "concurrency": 4 },
{ "componentFolder": "scheduler/viewOffset", "name": "scheduler / viewOffset (2/2)", "indices": "2/2", "concurrency": 4 },
{ "componentFolder": "scheduler/timezones", "name": "scheduler / timezones (Europe/Berlin)", "timezone": "Europe/Berlin" },
{ "componentFolder": "scheduler/timezones", "name": "scheduler / timezones (America/Los_Angeles)", "timezone": "America/Los_Angeles" }
]
JSON
)
style_dependent_matrix=$(cat <<'JSON'
[
{ "componentFolder": "accessibility", "name": "accessibility - fluent.dark", "theme": "fluent.blue.dark", "concurrency": 6 },
{ "componentFolder": "accessibility", "name": "accessibility - material.light", "theme": "material.blue.light", "concurrency": 6 },
{ "componentFolder": "accessibility", "name": "accessibility - material.dark", "theme": "material.blue.dark", "concurrency": 6 }
]
JSON
)
matrix=$(jq -c -n \
--argjson baseStart "$base_matrix_start" \
--argjson baseEnd "$base_matrix_end" \
--argjson styleDependent "$style_dependent_matrix" \
--arg stylesChanged "${{ needs.check-should-run.outputs.styles-changed }}" \
'{ include: ($baseStart + (if $stylesChanged == "true" then $styleDependent else [] end) + $baseEnd) }')
echo "matrix=$matrix" >> $GITHUB_OUTPUT
playwright:
name: ${{ matrix.name }}${{ !matrix.theme && ' - fluent' || '' }}
if: |
needs.check-should-run.outputs.should-run == 'true' &&
needs.determine-playwright-matrix.result == 'success' &&
needs.build.result == 'success'
needs: [check-should-run, build, determine-playwright-matrix]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.determine-playwright-matrix.outputs.matrix) }}
runs-on: devextreme-shr2
timeout-minutes: 45
steps:
- name: Get sources
uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: devextreme-artifacts-playwright
path: ./packages/devextreme
- name: Unpack artifacts
working-directory: ./packages/devextreme
run: 7z x artifacts.zip -aoa
- name: Setup Chrome
uses: ./.github/actions/setup-chrome
with:
chrome-version: '150.0.7871.181'
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.node-version'
- uses: pnpm/action-setup@v6
with:
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache/restore@v5
name: Restore pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-cache
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run Playwright tests
working-directory: ./e2e/playwright
env:
NODE_OPTIONS: --max-old-space-size=8192
# The browser context takes the timezone, so the agent clock is left alone.
TIMEZONE: ${{ matrix.timezone }}
run: |
THEME="--theme ${{ matrix.theme || 'fluent.blue.light' }}"
[ "${{ matrix.componentFolder }}" != "" ] && COMPONENT_FOLDER="--componentFolder ${{ matrix.componentFolder }}"
[ "${{ matrix.indices }}" != "" ] && INDICES="--indices ${{ matrix.indices }}"
[ "${{ matrix.concurrency }}" != "" ] && CONCURRENCY="--concurrency ${{ matrix.concurrency }}"
all_args="$COMPONENT_FOLDER $CONCURRENCY $INDICES $THEME"
echo "$all_args"
pnpm run test $all_args
- name: Sanitize job name
if: ${{ always() }}
run: echo "JOB_NAME=$(echo "${{ matrix.name }}" | tr '/' '-')" >> $GITHUB_ENV
- name: Upload test report
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: playwright-report-${{ env.JOB_NAME }}
path: ${{ github.workspace }}/e2e/playwright/artifacts/playwright-report
if-no-files-found: ignore
- name: Upload test traces and screenshot diffs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: playwright-traces-${{ env.JOB_NAME }}
path: ${{ github.workspace }}/e2e/playwright/artifacts/test-results
if-no-files-found: ignore
merge-artifacts:
runs-on: ubuntu-latest
needs: [playwright]
if: ${{ always() }}
steps:
- name: Detect mergeable artifacts
id: mergeable-artifacts
uses: actions/github-script@v9
with:
script: |
const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, {
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
per_page: 100,
});
const artifactGroups = {
reports: /^playwright-report-/,
traces: /^playwright-traces-/,
};
for (const [outputName, pattern] of Object.entries(artifactGroups)) {
const names = artifacts
.map((artifact) => artifact.name)
.filter((name) => pattern.test(name));
core.setOutput(outputName, names.length > 0 ? 'true' : 'false');
core.info(`${outputName}: ${names.length ? names.join(', ') : '(none)'}`);
}
- name: Merge test reports
if: steps.mergeable-artifacts.outputs.reports == 'true'
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
name: playwright-reports
pattern: playwright-report-*
separate-directories: true
delete-merged: true
- name: Merge test traces
if: steps.mergeable-artifacts.outputs.traces == 'true'
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
name: playwright-traces
pattern: playwright-traces-*
separate-directories: true
delete-merged: true