-
Notifications
You must be signed in to change notification settings - Fork 471
247 lines (216 loc) · 8.82 KB
/
e2e.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
name: ⚙️ E2E testing
on:
pull_request:
jobs:
build-demo:
if: ${{ !contains(github.head_ref , 'release/') }}
name: Build demo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
with:
fetch-depth: 10
- uses: taiga-family/ci/actions/setup/variables@v1.94.0
- uses: taiga-family/ci/actions/run/rebase@v1.94.0
continue-on-error: true
- uses: taiga-family/ci/actions/setup/node@v1.94.0
- run: npx nx type-check demo-playwright
- name: Building demo-app of git-branch without cache
run: npx nx build demo # Don't use prerender please, because it's flaky for e2e
- name: Upload cache / ${{ env.CACHE_DIST_KEY }}
uses: actions/cache/save@v4.1.2
with:
path: dist/demo
key: ${{ env.CACHE_DIST_KEY }}
cypress:
runs-on: ubuntu-latest
name: Cypress / Component Testing
env:
CYPRESS_BASELINE_REPO: 'baseline'
CYPRESS_RESULTS_FOLDER: 'projects/demo-cypress/tests-results'
CYPRESS_BASELINE_SNAPSHOTS: 'projects/demo-cypress/tests-results/snapshots/baseline'
CYPRESS_BASELINE_SNAPSHOTS_KEY: 'cy_baseline_${{ github.event.pull_request.head.sha }}'
steps:
- uses: actions/checkout@v4.2.2
with:
ref: ${{ github.base_ref }}
- uses: taiga-family/ci/actions/setup/variables@v1.94.0
- uses: taiga-family/ci/actions/setup/node@v1.94.0
- name: Run tests for baseline state
run: npx nx component-test demo-cypress
- name: Save Cypress Baseline Snapshots
uses: actions/upload-artifact@v4.4.3
with:
path: ${{env.CYPRESS_BASELINE_SNAPSHOTS}}
name: ${{env.CYPRESS_BASELINE_SNAPSHOTS_KEY}}
if-no-files-found: ignore
compression-level: 0
retention-days: 1
- uses: actions/checkout@v4.2.2
- uses: taiga-family/ci/actions/setup/variables@v1.94.0
- uses: taiga-family/ci/actions/setup/node@v1.94.0
- name: Download Cypress Baseline Snapshots
uses: actions/download-artifact@v4.1.8
with:
path: ${{env.CYPRESS_BASELINE_SNAPSHOTS}}
pattern: ${{ env.CYPRESS_BASELINE_SNAPSHOTS_KEY }}
merge-multiple: true
- name: Run tests for current state
run: npx nx component-test demo-cypress
- name: Prepare diff screenshots
run: |
npm install canvas
npx ts-node ./scripts/visual-testing/combine-cypress-failed-screenshots.ts
- name: Debug output
continue-on-error: true
run: tree ${{ env.CYPRESS_RESULTS_FOLDER }} -L 1
- name: Upload artifacts
uses: actions/upload-artifact@v4.4.3
with:
path: '${{ env.CYPRESS_RESULTS_FOLDER }}/**/*.diff.png'
name: ${{ env.CYPRESS_SNAPSHOTS_ARTIFACTS_KEY }}
if-no-files-found: ignore
compression-level: 0
retention-days: 1
playwright:
if: ${{ !contains(github.head_ref , 'release/') }}
runs-on: ubuntu-latest
needs: [build-demo]
strategy:
fail-fast: false
max-parallel: 9
matrix:
shard: [
# Chrome
{index: 1, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 2, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 3, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 4, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 5, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 6, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 7, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 8, os: 'ubuntu-latest', project: 'chromium', total: 9},
{index: 9, os: 'ubuntu-latest', project: 'chromium', total: 9},
]
name: Playwright / ${{ matrix.shard.os }} / ${{ matrix.shard.index }} of ${{ matrix.shard.total }}
steps:
- uses: actions/checkout@v4.2.2
- uses: taiga-family/ci/actions/setup/variables@v1.94.0
- uses: taiga-family/ci/actions/setup/node@v1.94.0
- name: Get installed Playwright version
id: playwright-version
run: |
echo "PLAYWRIGHT_VERSION=$(node -p 'require("./projects/demo-playwright/package.json").devDependencies["@playwright/test"]')" >> $GITHUB_ENV
- uses: actions/cache/restore@v4.1.2
id: playwright-cache
with:
path: |
~/Library/Caches/ms-playwright
~/.cache/ms-playwright
**/node_modules/playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- run: npx playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- run: npx playwright install-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Download cache / ${{ env.CACHE_DIST_KEY }}
uses: actions/cache/restore@v4.1.2
with:
path: dist/demo
key: ${{ env.CACHE_DIST_KEY }}
- uses: taiga-family/ci/actions/run/serve@v1.94.0
with:
port: ${{ env.NG_SERVER_PORT }}
directory: ${{ env.DIST }}
replaceBaseUrl: false
- name: Run screenshot tests on ${{ env.DIST }}
run: |
npx nx e2e demo-playwright -- \
--update-snapshots \
--project=${{ matrix.shard.project }} \
--shard=${{ matrix.shard.index }}/${{ matrix.shard.total }}
- uses: taiga-family/ci/actions/run/clone@v1.94.0
with:
branch: snapshots/demo/next/${{ github.base_ref }}
destination: ${{ env.DIST_NEXT }}
- uses: taiga-family/ci/actions/run/serve@v1.94.0
with:
port: ${{ env.NG_SERVER_PORT }}
directory: ${{ env.DIST_NEXT }}
replaceBaseUrl: false
- name: Run screenshot tests on ${{ env.DIST_NEXT }}
continue-on-error: true
run: |
npx nx e2e demo-playwright -- \
--project=${{ matrix.shard.project }} \
--shard=${{ matrix.shard.index }}/${{ matrix.shard.total }}
- name: Combine images to get diff reports
run: |
npm install canvas
npm view canvas version
npx ts-node ./scripts/visual-testing/combine-playwright-failed-screenshots.ts
- name: Debug output
continue-on-error: true
run: tree ${{ env.PLAYWRIGHT_SNAPSHOTS_PATH }}
- name: Upload artifacts / ${{ env.PLAYWRIGHT_SNAPSHOTS_ARTIFACTS_KEY }}
uses: actions/upload-artifact@v4.4.3
with:
path: |
./projects/demo-playwright/tests-results/**/*.diff.png
!./projects/demo-playwright/tests-results/**/*-retry*/*.diff.png
name: '${{ env.PLAYWRIGHT_SNAPSHOTS_ARTIFACTS_KEY }}_${{ matrix.shard.project }}_${{ matrix.shard.index }}'
if-no-files-found: ignore
compression-level: 0
retention-days: 1
# workaround for status checks -- check this one job instead of each individual E2E job in the matrix
# see https://github.com/orgs/community/discussions/9141#discussioncomment-2296809
playwright-composite-result:
name: Playwright E2E Tests matrix result
if: ${{ always() }}
needs: [playwright]
runs-on: ubuntu-latest
steps:
- run: |
result="${{ needs.playwright.result }}"
# mark as successful even if skipped
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi
result:
if: ${{ !contains(github.head_ref , 'release/') }}
name: E2E result
needs: [playwright, cypress]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: taiga-family/ci/actions/setup/variables@v1.94.0
- name: Download artifacts for Playwright
continue-on-error: true
uses: actions/download-artifact@v4.1.8
with:
path: ./total/playwright
pattern: ${{ env.PLAYWRIGHT_SNAPSHOTS_ARTIFACTS_KEY }}_*
merge-multiple: true
- run: ls -R ./total/playwright || echo "not found"
- name: Download artifacts for Cypress
continue-on-error: true
uses: actions/download-artifact@v4.1.8
with:
path: ./total/cypress
pattern: ${{ env.CYPRESS_SNAPSHOTS_ARTIFACTS_KEY }}
merge-multiple: true
- run: ls -R ./total/cypress || echo "not found"
- name: Check if diff-output exists
id: diff_checker
run: |
echo "diff_exist=$(find ./total -regex '.*diff\.png$' | wc -l | sed -e 's/^[[:space:]]*//')" >> $GITHUB_OUTPUT
- name: Fall with an error if diff-output exists
if: ${{ steps.diff_checker.outputs.diff_exist != '0' }}
run: |
find ./total -regex '.*diff\.png$' -exec echo "{}" \;
exit 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true