-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
335 lines (295 loc) · 13 KB
/
visual-snapshots.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
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# Visual Snapshots compares against artifacts from the same workflow name (on main branch)
name: visual-snapshots
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
# hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
jobs:
take-master-acceptance-snapshots:
name: Take Default Branch Acceptance Snapshots
runs-on: ubuntu-20.04
if: |
contains( github.event.pull_request.labels.*.name, 'Trigger: Visual Snapshot')
timeout-minutes: 25
strategy:
# This helps not having to run multiple jobs because one fails, thus, reducing resource usage
# and reducing the risk that one of many runs would turn red again (read: intermittent tests)
fail-fast: false
matrix:
# XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
instance: [0, 1, 2]
pg-version: ['14']
env:
# XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance.
MATRIX_INSTANCE_TOTAL: 3
VISUAL_SNAPSHOT_ENABLE: 1
TEST_GROUP_STRATEGY: roundrobin
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
name: Checkout sentry
with:
ref: 'master'
- uses: getsentry/action-setup-volta@54775a59c41065f54ecc76d1dd5f2cdc7a1550cb # v1.1.0
- name: Step configurations
id: config
run: echo "webpack-path=.webpack_cache" >> "$GITHUB_OUTPUT"
- name: webpack cache
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: ${{ steps.config.outputs.webpack-path }}
key: ${{ runner.os }}-v2-webpack-cache-${{ hashFiles('webpack.config.ts') }}
- name: node_modules cache
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
id: nodemodulescache
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
- name: Install Javascript Dependencies
if: steps.nodemodulescache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: webpack
env:
WEBPACK_CACHE_PATH: ${{ steps.config.outputs.webpack-path }}
SENTRY_INSTRUMENTATION: 1
# this is fine to not have for forks, it shouldn't fail
SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
run: |
yarn build-acceptance
- name: Build chartcuterie configuration module
run: |
make build-chartcuterie-config
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
id: setup
with:
snuba: true
chartcuterie: true
pg-version: ${{ matrix.pg-version }}
- name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
run: |
mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-mobile
mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-tooltips
make run-acceptance
env:
PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
- name: Save snapshots
uses: getsentry/action-visual-snapshot@f2537eaa143289fc5d246370767fb6cb5eff1e12
with:
save-only: true
artifact-name: 'acceptance-visual-snapshots-base'
snapshot-path: .artifacts/visual-snapshots
take-pr-acceptance-snapshots:
name: Take PR Acceptance Snapshots
runs-on: ubuntu-20.04
if: |
contains( github.event.pull_request.labels.*.name, 'Trigger: Visual Snapshot')
timeout-minutes: 25
strategy:
# This helps not having to run multiple jobs because one fails, thus, reducing resource usage
# and reducing the risk that one of many runs would turn red again (read: intermittent tests)
fail-fast: false
matrix:
# XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
instance: [0, 1, 2]
pg-version: ['14']
env:
# XXX: MATRIX_INSTANCE_TOTAL must be hardcoded to the length of strategy.matrix.instance.
MATRIX_INSTANCE_TOTAL: 3
VISUAL_SNAPSHOT_ENABLE: 1
TEST_GROUP_STRATEGY: roundrobin
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
name: Checkout sentry
- uses: getsentry/action-setup-volta@54775a59c41065f54ecc76d1dd5f2cdc7a1550cb # v1.1.0
- name: Step configurations
id: config
run: echo "webpack-path=.webpack_cache" >> "$GITHUB_OUTPUT"
- name: webpack cache
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: ${{ steps.config.outputs.webpack-path }}
key: ${{ runner.os }}-v2-webpack-cache-${{ hashFiles('webpack.config.ts') }}
- name: node_modules cache
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
id: nodemodulescache
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
- name: Install Javascript Dependencies
if: steps.nodemodulescache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: webpack
env:
WEBPACK_CACHE_PATH: ${{ steps.config.outputs.webpack-path }}
SENTRY_INSTRUMENTATION: 1
# this is fine to not have for forks, it shouldn't fail
SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }}
run: |
yarn build-acceptance
- name: Build chartcuterie configuration module
run: |
make build-chartcuterie-config
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
id: setup
with:
snuba: true
chartcuterie: true
pg-version: ${{ matrix.pg-version }}
- name: Run acceptance tests (#${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
run: |
mkdir -p ${{ steps.setup.outputs.acceptance-dir }}
mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-mobile
mkdir -p ${{ steps.setup.outputs.acceptance-dir }}-tooltips
make run-acceptance
env:
PYTEST_SNAPSHOTS_DIR: ${{ steps.setup.outputs.acceptance-dir }}
- name: Save snapshots
uses: getsentry/action-visual-snapshot@f2537eaa143289fc5d246370767fb6cb5eff1e12
with:
save-only: true
artifact-name: 'acceptance-visual-snapshots-pr'
snapshot-path: .artifacts/visual-snapshots
diff-acceptance-snapshots:
name: Diff Acceptance snapshots
needs: [take-master-acceptance-snapshots, take-pr-acceptance-snapshots]
runs-on: ubuntu-20.04
if: |
contains( github.event.pull_request.labels.*.name, 'Trigger: Visual Snapshot')
timeout-minutes: 25
steps:
- name: Diff snapshots
uses: getsentry/action-visual-snapshot@f2537eaa143289fc5d246370767fb6cb5eff1e12
with:
action-name: 'Visual Snapshot: Acceptance'
api-token: ${{ secrets.VISUAL_SNAPSHOT_SECRET }}
gcs-bucket: 'sentry-visual-snapshots'
gcp-service-account-key: ${{ secrets.SNAPSHOT_GOOGLE_SERVICE_ACCOUNT_KEY }}
base-artifact-name: 'acceptance-visual-snapshots-base'
base-branch: ''
artifact-name: 'acceptance-visual-snapshots-pr'
take-master-frontend-snapshots:
name: Take Default Branch Frontend Snapshots
runs-on: ubuntu-20.04
if: |
contains( github.event.pull_request.labels.*.name, 'Trigger: Visual Snapshot')
timeout-minutes: 30
strategy:
# This helps not having to run multiple jobs because one fails, thus, reducing resource usage
# and reducing the risk that one of many runs would turn red again (read: intermittent tests)
fail-fast: false
matrix:
# XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
instance: [0, 1, 2, 3]
env:
VISUAL_HTML_ENABLE: 1
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
name: Checkout sentry
with:
ref: 'master'
- uses: getsentry/action-setup-volta@54775a59c41065f54ecc76d1dd5f2cdc7a1550cb # v1.1.0
- name: node_modules cache
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
id: nodemodulescache
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
- name: Install Javascript Dependencies
if: steps.nodemodulescache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Build CSS
run: NODE_ENV=production yarn build-css
- name: jest
env:
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }}
CI_NODE_TOTAL: 4
CI_NODE_INDEX: ${{ matrix.instance }}
run: |
SENTRY_PROFILER_LOGGING_MODE=eager JEST_TESTS=$(yarn -s jest --listTests --json) yarn test-ci --forceExit
- name: Create Images from HTML
uses: getsentry/action-html-to-image@dc153dae538e6e1138f77156d8e62e3b2b897f41 # main
with:
base-path: .artifacts/visual-snapshots/jest
css-path: src/sentry/static/sentry/dist/entrypoints/sentry.css
- name: Save snapshots
uses: getsentry/action-visual-snapshot@f2537eaa143289fc5d246370767fb6cb5eff1e12
with:
save-only: true
artifact-name: 'frontend-visual-snapshots-base'
snapshot-path: .artifacts/visual-snapshots
take-pr-frontend-snapshots:
name: Take PR Frontend Snapshots
runs-on: ubuntu-20.04
if: |
contains( github.event.pull_request.labels.*.name, 'Trigger: Visual Snapshot')
timeout-minutes: 30
strategy:
# This helps not having to run multiple jobs because one fails, thus, reducing resource usage
# and reducing the risk that one of many runs would turn red again (read: intermittent tests)
fail-fast: false
matrix:
instance: [0, 1, 2, 3]
env:
VISUAL_HTML_ENABLE: 1
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
name: Checkout sentry
- uses: getsentry/action-setup-volta@54775a59c41065f54ecc76d1dd5f2cdc7a1550cb # v1.1.0
- name: node_modules cache
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
id: nodemodulescache
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock', 'api-docs/yarn.lock') }}
- name: Install Javascript Dependencies
if: steps.nodemodulescache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Build CSS
run: NODE_ENV=production yarn build-css
- name: jest
env:
GITHUB_PR_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
GITHUB_PR_REF: ${{ github.event.pull_request.head.ref || github.ref }}
CI_NODE_TOTAL: 4
CI_NODE_INDEX: ${{ matrix.instance }}
run: |
SENTRY_PROFILER_LOGGING_MODE=eager JEST_TESTS=$(yarn -s jest --listTests --json) yarn test-ci --forceExit
- name: Create Images from HTML
uses: getsentry/action-html-to-image@dc153dae538e6e1138f77156d8e62e3b2b897f41 # main
with:
base-path: .artifacts/visual-snapshots/jest
css-path: src/sentry/static/sentry/dist/entrypoints/sentry.css
- name: Save snapshots
uses: getsentry/action-visual-snapshot@f2537eaa143289fc5d246370767fb6cb5eff1e12
with:
save-only: true
artifact-name: 'frontend-visual-snapshots-pr'
snapshot-path: .artifacts/visual-snapshots
diff-frontend-snapshots:
name: Diff Frontend snapshots
needs: [take-master-frontend-snapshots, take-pr-frontend-snapshots]
runs-on: ubuntu-20.04
if: |
contains( github.event.pull_request.labels.*.name, 'Trigger: Visual Snapshot')
timeout-minutes: 25
steps:
- name: Diff snapshots
uses: getsentry/action-visual-snapshot@f2537eaa143289fc5d246370767fb6cb5eff1e12
with:
action-name: 'Visual Snapshot: Frontend'
api-token: ${{ secrets.VISUAL_SNAPSHOT_SECRET }}
gcs-bucket: 'sentry-visual-snapshots'
gcp-service-account-key: ${{ secrets.SNAPSHOT_GOOGLE_SERVICE_ACCOUNT_KEY }}
base-artifact-name: 'frontend-visual-snapshots-base'
base-branch: ''
artifact-name: 'frontend-visual-snapshots-pr'