-
Notifications
You must be signed in to change notification settings - Fork 5
130 lines (113 loc) · 4.84 KB
/
playwright.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
name: Playwright tests
on:
workflow_call:
inputs:
update-snapshots:
type: boolean
default: false
description: Whether to update snapshots / screenshots
jobs:
playwright:
strategy:
fail-fast: false
matrix:
# to optimize the speed of the screenshot generation, we are using Playwright sharding
# to split up the tests in smaller chunks and run them in parallel
# for further details, see: https://playwright.dev/docs/test-sharding
# more shards can be added below to speed up the executing time if more screenshots are added in the future
# note: GitHub's limit is 256 parallel (see https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#using-a-matrix-strategy)
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
name: Playwright shard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/templates/node-setup
# install system dependencies for Playwright
# see: https://playwright.dev/python/docs/browsers#install-system-dependencies
- name: 📦 Install Playwright system dependencies
run: pnpm exec playwright install-deps
- name: 🔎 Run Playwright tests
run: pnpm run test:components:all -- --shard=${{ matrix.shard }}/${{ strategy.job-total }} ${{ inputs.update-snapshots == true && '--update-snapshots' || '' }}
# we only want to include actual changed screenshots in the artifact to prevent that old/unchanged screenshots
# override changed screenshots from other shards when creating the pull request
- name: Copy changed files
if: ${{ inputs.update-snapshots == true }}
run: |
mkdir ./changed-screenshots
rsync -R $(git ls-files --others --modified --exclude-standard) ./changed-screenshots/ || echo "no changed files found"
- name: Upload screenshots artifact
uses: actions/upload-artifact@v4
if: ${{ inputs.update-snapshots == true }}
with:
name: screenshots-${{ matrix.shard }}
path: changed-screenshots
# prevent warnings if shard does not update any screenshots
if-no-files-found: ignore
- name: Upload Reports
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: blob-report-${{ matrix.shard }}
path: |
./packages/*/blob-report
./apps/*/blob-report
retention-days: 1
# this final step is needed to we can set make the Playwright tests a required check in pull requests
# because we don't want to add each parallel matrix job individually
# see: https://github.com/orgs/community/discussions/26822#discussioncomment-3305794
playwright-result:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Collect Playwright result
needs: playwright
steps:
- uses: actions/checkout@v4
- name: Merge Screenshots
uses: actions/upload-artifact/merge@v4
if: ${{ !cancelled() }}
continue-on-error: true
with:
name: screenshots
pattern: screenshots-*
delete-merged: true
- name: Merge Reports
uses: actions/upload-artifact/merge@v4
if: ${{ !cancelled() }}
with:
name: blob-reports
pattern: blob-report-*
retention-days: 1
delete-merged: true
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- name: 📦 Install dependencies
run: pnpm install
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
name: blob-reports
# For every blob-report merge its playwright results as html report and move it into its original package
- name: Merge into HTML Report
run: find . -type d -name blob-report | xargs -n1 -I {} sh -c 'npx playwright merge-reports --reporter html {} && mv playwright-report {}/../playwright-report'
# The html report can be manually downloaded and after extraction a static file server can be used to show the results.
# A file server is necessary, otherwise not all features are supported.
# E.g. use `python3 -m http.server` or `npx serve` to quick and easily start one.
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: |
./packages/*/playwright-report
./apps/*/playwright-report
retention-days: 14
- run: |
result="${{ needs.playwright.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi