-
Notifications
You must be signed in to change notification settings - Fork 0
244 lines (203 loc) · 7.41 KB
/
visual-regression-test.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
name: visual-regression-test
on:
pull_request:
branches:
- main
defaults:
run:
shell: bash
jobs:
check_expected_screenshots:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: volta-cli/action@v4
- uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
- name: restore cached expected screenshots
id: screenshots_cache
uses: ./.github/actions/cache-screenshots
with:
lookup-only: 'true'
- name: restore cached node_modules
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
uses: ./.github/actions/cache-node-modules
- name: cache storybook build result
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
id: storybook_result_cache
uses: ./.github/actions/cache-storybook-build-result
- name: storybook build
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' && steps.storybook_result_cache.outputs.cache-hit != 'true' }}
run: yarn storybook:build
env:
NEXT_IS_TEST: 'true'
take_expected_screenshots:
needs: check_expected_screenshots
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- uses: volta-cli/action@v4
- uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
- name: restore cached expected screenshots
id: screenshots_cache
uses: ./.github/actions/cache-screenshots
with:
lookup-only: 'false'
- name: restore cached node_modules
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
uses: ./.github/actions/cache-node-modules
- name: cache storybook build result
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
id: storybook_result_cache
uses: ./.github/actions/cache-storybook-build-result
- name: prepare for screenshots
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
uses: ./.github/actions/prepare-screenshots
- name: take screenshots
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
run: yarn storybook:screenshot --shard=${{ matrix.shard }}
- name: upload screenshots
uses: actions/upload-artifact@v3
with:
name: expected-screenshots
path: __screenshots__
retention-days: 1
check_actual_screenshots:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: volta-cli/action@v4
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: workaround for detached HEAD
run: |
git checkout ${GITHUB_HEAD_REF#refs/heads/} || git checkout -b ${GITHUB_HEAD_REF#refs/heads/} && git pull
- name: restore cached actual screenshots
id: screenshots_cache
uses: ./.github/actions/cache-screenshots
with:
lookup-only: 'true'
- name: restore cached node_modules
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
uses: ./.github/actions/cache-node-modules
- name: cache storybook build result
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
id: storybook_result_cache
uses: ./.github/actions/cache-storybook-build-result
- name: storybook build
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' && steps.storybook_result_cache.outputs.cache-hit != 'true' }}
run: yarn storybook:build
env:
NEXT_IS_TEST: 'true'
take_actual_screenshots:
needs: check_actual_screenshots
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- uses: volta-cli/action@v4
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: workaround for detached HEAD
run: |
git checkout ${GITHUB_HEAD_REF#refs/heads/} || git checkout -b ${GITHUB_HEAD_REF#refs/heads/} && git pull
- name: restore cached actual screenshots
id: screenshots_cache
uses: ./.github/actions/cache-screenshots
with:
lookup-only: 'false'
- name: restore cached node_modules
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
uses: ./.github/actions/cache-node-modules
- name: cache storybook build result
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
id: storybook_result_cache
uses: ./.github/actions/cache-storybook-build-result
- name: prepare for screenshots
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
uses: ./.github/actions/prepare-screenshots
- name: take screenshots
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
run: yarn storybook:screenshot --shard=${{ matrix.shard }}
- name: upload screenshots
uses: actions/upload-artifact@v3
with:
name: actual-screenshots
path: __screenshots__
retention-days: 1
run_reg_suit:
needs:
- take_expected_screenshots
- take_actual_screenshots
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: volta-cli/action@v4
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: restore cached expected screenshots
id: screenshots_cache
uses: ./.github/actions/cache-screenshots
with:
lookup-only: 'false'
- name: download expected screenshots
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
uses: actions/download-artifact@v3
with:
name: expected-screenshots
path: __screenshots__
- name: set reg-suit expected
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
run: |
rm -rf .reg/expected/
mkdir -p .reg/expected
mv -f __screenshots__/* .reg/expected/
ls -l .reg/
- name: download actual screenshots
uses: actions/download-artifact@v3
with:
name: actual-screenshots
path: __screenshots__
- name: restore cached node_modules
if: ${{ steps.screenshots_cache.outputs.cache-hit != 'true' }}
uses: ./.github/actions/cache-node-modules
- name: workaround for detached HEAD
run: |
git checkout ${GITHUB_HEAD_REF#refs/heads/} || git checkout -b ${GITHUB_HEAD_REF#refs/heads/} && git pull
- name: run reg-suit
run: yarn test:vrt
- name: deploy report to github page
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .reg/
destination_dir: ${{ github.head_ref }}
- name: find comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: reg-suit report
- name: upsert comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
reg-suit report
https://funteractive-inc.github.io/ocapi-frontend/${{github.head_ref}}
edit-mode: replace