-
Notifications
You must be signed in to change notification settings - Fork 471
203 lines (168 loc) · 7.01 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
name: ⚙️ E2E tests
on:
pull_request:
env:
CYPRESS_failOnSnapshotDiff: 0
PLAYWRIGHT_SNAPSHOTS_PATH: ./projects/demo-playwright/tests-results
CYPRESS_SNAPSHOTS_PATH: ./projects/demo-cypress/cypress/snapshots
jobs:
build-demo:
if: ${{ !contains(github.head_ref , 'release/') }}
name: Build demo
runs-on: ubuntu-latest
steps:
- uses: taiga-family/ci/actions/setup/[email protected]
with:
fetch-depth: 10
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/run/[email protected]
continue-on-error: true
- uses: taiga-family/ci/actions/setup/[email protected]
- name: Building demo-app of git-branch without cache
run: npx nx build demo -c next --output-path ${{ env.DIST }} --base-href='/'
- name: Upload cache / ${{ env.CACHE_DIST_KEY }}
uses: actions/cache/[email protected]
with:
path: dist/demo
key: ${{ env.CACHE_DIST_KEY }}
cypress:
if: ${{ !contains(github.head_ref , 'release/') }}
needs: [build-demo]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [core, deep, kit]
name: ${{ matrix.project }}
steps:
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/setup/[email protected]
- name: Download cache / ${{ env.CACHE_DIST_KEY }}
uses: actions/cache/[email protected]
with:
path: dist/demo
key: ${{ env.CACHE_DIST_KEY }}
- name: Serve ${{ env.DIST }} in background
run: npx nx serve-compiled demo --path ${{ env.DIST }} --port ${{ env.NG_SERVER_PORT }}
- name: Run screenshot tests on ${{ env.DIST }}
run: npx nx e2e demo-cypress --folder ${{ matrix.project }}
- name: Clean up resources
run: npx kill-port --port ${{ env.NG_SERVER_PORT }}
- name: Download ${{ env.DIST_NEXT }} for serve locally
run: |
git clone \
--depth 1 \
--branch snapshots/demo/next/${{ github.base_ref }} \
https://github.com/taiga-family/taiga-ui.git ${{ env.DIST_NEXT }}
- name: Serve ${{ env.DIST_NEXT }} in background
run: npx nx serve-compiled demo --path ${{ env.DIST_NEXT }} --port ${{ env.NG_SERVER_PORT }}
- name: Run screenshot tests on ${{ env.DIST_NEXT }}
continue-on-error: true
run: npx nx e2e demo-cypress --folder ${{ matrix.project }}
- name: Clean up resources
run: npx kill-port --port ${{ env.NG_SERVER_PORT }}
- name: Debug output
continue-on-error: true
run: tree ${{ env.CYPRESS_SNAPSHOTS_PATH }}
- name: Upload artifacts / ${{ env.CYPRESS_SNAPSHOTS_ARTIFACTS_KEY }}
uses: actions/[email protected]
with:
path: ${{ env.CYPRESS_SNAPSHOTS_PATH }}/**/*.diff.png
name: ${{ env.CYPRESS_SNAPSHOTS_ARTIFACTS_KEY }}
if-no-files-found: ignore
retention-days: 1
playwright:
if: ${{ !contains(github.head_ref , 'release/') }}
runs-on: ubuntu-latest
needs: [build-demo]
env:
max_parallel: 4
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
name: playwright / (${{ matrix.shard }} of 4)
steps:
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/setup/[email protected]
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Download cache / ${{ env.CACHE_DIST_KEY }}
uses: actions/cache/[email protected]
with:
path: dist/demo
key: ${{ env.CACHE_DIST_KEY }}
- name: Serve ${{ env.DIST }} in background
run: npx nx serve-compiled demo --path ${{ env.DIST }} --port ${{ env.NG_SERVER_PORT }}
- name: Run screenshot tests on ${{ env.DIST }}
run: npx nx e2e demo-playwright -- --update-snapshots --shard=${{ matrix.shard }}/${{ env.max_parallel }}
- name: Clean up resources
run: npx kill-port --port ${{ env.NG_SERVER_PORT }}
- name: Download ${{ env.DIST_NEXT }} for serve locally
run: |
git clone \
--depth 1 \
--branch snapshots/demo/next/${{ github.base_ref }} \
https://github.com/taiga-family/taiga-ui.git ${{ env.DIST_NEXT }}
- name: Find and replace baseHref for next snapshot
uses: jacobtomlinson/gha-find-replace@v3
with:
find: '<base href="./">'
replace: '<base href="/">'
include: '${{ env.DIST_NEXT }}/index.html'
regex: false
- name: Serve ${{ env.DIST_NEXT }} in background
run: npx nx serve-compiled demo --path ${{ env.DIST_NEXT }} --port ${{ env.NG_SERVER_PORT }}
- name: Run screenshot tests on ${{ env.DIST_NEXT }}
continue-on-error: true
run: npx nx e2e demo-playwright --shard=${{ matrix.shard }}/${{ env.max_parallel }}
- name: Clean up resources
run: npx kill-port --port ${{ env.NG_SERVER_PORT }}
- name: Combine images to get diff reports
run: |
npm install canvas
npx ts-node ./scripts/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/[email protected]
with:
path: ${{ env.PLAYWRIGHT_SNAPSHOTS_PATH }}/**/*.diff.png
name: ${{ env.PLAYWRIGHT_SNAPSHOTS_ARTIFACTS_KEY }}
if-no-files-found: ignore
retention-days: 1
result:
if: ${{ !contains(github.head_ref , 'release/') }}
name: E2E result
needs: [cypress, playwright]
runs-on: ubuntu-latest
steps:
- uses: taiga-family/ci/actions/setup/[email protected]
- uses: taiga-family/ci/actions/setup/[email protected]
- name: Download artifacts / ${{ env.CYPRESS_SNAPSHOTS_ARTIFACTS_KEY }}
continue-on-error: true
uses: actions/[email protected]
with:
name: ${{ env.CYPRESS_SNAPSHOTS_ARTIFACTS_KEY }}
path: ./total/cypress
- name: Download artifacts / ${{ env.PLAYWRIGHT_SNAPSHOTS_ARTIFACTS_KEY }}
continue-on-error: true
uses: actions/[email protected]
with:
name: ${{ env.PLAYWRIGHT_SNAPSHOTS_ARTIFACTS_KEY }}
path: ./total/playwright
- 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: e2e-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true