-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
393 lines (346 loc) · 13 KB
/
backend.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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
name: backend
on:
push:
branches:
- master
pull_request:
# 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:
files-changed:
name: detect what files changed
runs-on: ubuntu-20.04
timeout-minutes: 3
# Map a step output to a job output
outputs:
api_docs: ${{ steps.changes.outputs.api_docs }}
backend: ${{ steps.changes.outputs.backend_all }}
backend_dependencies: ${{ steps.changes.outputs.backend_dependencies }}
backend_any_type: ${{ steps.changes.outputs.backend_any_type }}
migration_lockfile: ${{ steps.changes.outputs.migration_lockfile }}
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- name: Check for backend file changes
uses: getsentry/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changes
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
api-docs:
if: needs.files-changed.outputs.api_docs == 'true'
needs: files-changed
name: api docs test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- uses: getsentry/action-setup-volta@54775a59c41065f54ecc76d1dd5f2cdc7a1550cb # v1.1.0
- name: Setup sentry python env
uses: ./.github/actions/setup-sentry
id: setup
with:
snuba: true
- name: Run API docs tests
# install ts-node for ts build scripts to execute properly without potentially installing
# conflicting deps when running scripts locally
# see: https://github.com/getsentry/sentry/pull/32328/files
run: |
yarn add ts-node && make test-api-docs
backend-test:
if: needs.files-changed.outputs.backend == 'true'
needs: files-changed
name: backend test
runs-on: ubuntu-20.04
timeout-minutes: 40
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, 4, 5, 6, 7, 8, 9, 10]
pg-version: ['14']
env:
# XXX: `MATRIX_INSTANCE_TOTAL` must be hardcoded to the length of `strategy.matrix.instance`.
# If this increases, make sure to also increase `flags.backend.after_n_builds` in `codecov.yml`.
MATRIX_INSTANCE_TOTAL: 11
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
# Avoid codecov error message related to SHA resolution:
# https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
fetch-depth: '2'
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
id: setup
with:
kafka: true
snuba: true
# Right now, we run so few bigtable related tests that the
# overhead of running bigtable in all backend tests
# is way smaller than the time it would take to run in its own job.
bigtable: true
pg-version: ${{ matrix.pg-version }}
- name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
run: |
make test-python-ci
# Upload coverage data even if running the tests step fails since
# it reduces large coverage fluctuations
- name: Handle artifacts
if: ${{ always() }}
uses: ./.github/actions/artifacts
with:
token: ${{ secrets.CODECOV_TOKEN }}
backend-migration-tests:
if: needs.files-changed.outputs.backend == 'true'
needs: files-changed
name: backend migration tests
runs-on: ubuntu-20.04
timeout-minutes: 30
strategy:
matrix:
pg-version: ['14']
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
# Avoid codecov error message related to SHA resolution:
# https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
fetch-depth: '2'
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
id: setup
with:
snuba: true
pg-version: ${{ matrix.pg-version }}
- name: run tests
run: |
MIGRATIONS_TEST_MIGRATE=1 PYTEST_ADDOPTS="$PYTEST_ADDOPTS -m migrations" make test-python-ci
# Upload coverage data even if running the tests step fails since
# it reduces large coverage fluctuations
- name: Handle artifacts
if: ${{ always() }}
uses: ./.github/actions/artifacts
with:
token: ${{ secrets.CODECOV_TOKEN }}
cli:
if: needs.files-changed.outputs.backend == 'true'
needs: files-changed
name: cli test
runs-on: ubuntu-20.04
timeout-minutes: 10
strategy:
matrix:
pg-version: ['14']
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
id: setup
with:
pg-version: ${{ matrix.pg-version }}
- name: Run test
run: |
make test-cli
# Upload coverage data even if running the tests step fails since
# it reduces large coverage fluctuations
- name: Handle artifacts
if: ${{ always() }}
uses: ./.github/actions/artifacts
with:
token: ${{ secrets.CODECOV_TOKEN }}
requirements:
if: needs.files-changed.outputs.backend_dependencies == 'true'
needs: files-changed
name: requirements check
runs-on: ubuntu-20.04
timeout-minutes: 3
steps:
- uses: getsentry/action-github-app-token@97c9e23528286821f97fba885c1b1123284b29cc # v2.0.0
id: token
continue-on-error: true
with:
app_id: ${{ vars.SENTRY_INTERNAL_APP_ID }}
private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }}
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- uses: getsentry/action-setup-venv@9e3bbae3836b1b6f129955bf55a19e1d99a61c67 # v1.0.5
with:
python-version: 3.8.16
cache-depedency: requirements-dev-frozen.txt
install-cmd: pip install -q --constraint requirements-dev-frozen.txt pip-tools
- name: check requirements
run: |
python -S -m tools.freeze_requirements
if ! git diff --exit-code; then
echo $'\n\nrun `make freeze-requirements` locally to update requirements'
exit 1
fi
- name: apply any requirements changes
if: steps.token.outcome == 'success' && github.ref != 'refs/heads/master' && always()
uses: getsentry/action-github-commit@748c31dd78cffe76f51bef49a0be856b6effeda7 # v1.1.0
with:
github-token: ${{ steps.token.outputs.token }}
message: ':snowflake: re-freeze requirements'
migration:
if: needs.files-changed.outputs.migration_lockfile == 'true'
needs: files-changed
name: check migration
runs-on: ubuntu-20.04
strategy:
matrix:
pg-version: ['14']
steps:
- name: Checkout sentry
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
id: setup
with:
pg-version: ${{ matrix.pg-version }}
- name: Migration & lockfile checks
env:
SENTRY_LOG_LEVEL: ERROR
PGPASSWORD: postgres
run: |
./.github/workflows/scripts/migration-check.sh
relay:
if: needs.files-changed.outputs.backend == 'true'
needs: files-changed
name: relay test
runs-on: ubuntu-20.04
timeout-minutes: 30
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
# Avoid codecov error message related to SHA resolution:
# https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
fetch-depth: '2'
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
id: setup
with:
snuba: true
kafka: true
- name: Pull relay image
run: |
# pull relay we'll run and kill it for each test
docker pull us.gcr.io/sentryio/relay:nightly
docker ps -a
- name: Run test
env:
SENTRY_FORCE_SILOED_TESTS: 1
run: |
make test-relay-integration
# Upload coverage data even if running the tests step fails since
# it reduces large coverage fluctuations
- name: Handle artifacts
if: ${{ always() }}
uses: ./.github/actions/artifacts
with:
token: ${{ secrets.CODECOV_TOKEN }}
symbolicator:
if: needs.files-changed.outputs.backend == 'true'
needs: files-changed
name: symbolicator test
runs-on: ubuntu-20.04
timeout-minutes: 20
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
# Avoid codecov error message related to SHA resolution:
# https://github.com/codecov/codecov-bash/blob/7100762afbc822b91806a6574658129fe0d23a7d/codecov#L891
fetch-depth: '2'
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
id: setup
with:
snuba: true
kafka: true
- name: Start symbolicator
run: |
echo $PWD
docker run \
-d \
-v $PWD/config/symbolicator/:/etc/symbolicator \
--network host \
--name symbolicator \
us.gcr.io/sentryio/symbolicator:nightly \
run -c /etc/symbolicator/config.yml
docker ps -a
- name: Run test
run: |
make test-symbolicator
# Upload coverage data even if running the tests step fails since
# it reduces large coverage fluctuations
- name: Handle artifacts
if: ${{ always() }}
uses: ./.github/actions/artifacts
with:
token: ${{ secrets.CODECOV_TOKEN }}
typing:
if: needs.files-changed.outputs.backend == 'true'
needs: files-changed
name: backend typing
runs-on: ubuntu-20.04
timeout-minutes: 20
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- uses: getsentry/action-setup-venv@9e3bbae3836b1b6f129955bf55a19e1d99a61c67 # v1.0.5
with:
python-version: 3.8.16
cache-dependency-path: requirements-dev-frozen.txt
install-cmd: pip install -r requirements-dev-frozen.txt
- name: setup sentry (lite)
run: |
SENTRY_LIGHT_BUILD=1 pip install --no-deps -e .
sentry init
- run: make backend-typing
id: run
- uses: getsentry/action-github-app-token@97c9e23528286821f97fba885c1b1123284b29cc # v2.0.0
id: token
continue-on-error: true
with:
app_id: ${{ vars.SENTRY_INTERNAL_APP_ID }}
private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }}
# only if `backend-typing` succeeds should we try and trim the blocklist
- run: |
python3 -m tools.mypy_helpers.make_module_ignores
git diff --exit-code
- name: apply blocklist changes
if: steps.token.outcome == 'success' && steps.run.outcome == 'success' && github.ref != 'refs/heads/master' && always()
uses: getsentry/action-github-commit@748c31dd78cffe76f51bef49a0be856b6effeda7 # v1.1.0
with:
github-token: ${{ steps.token.outputs.token }}
message: ':knife: regenerate mypy module blocklist'
# This check runs once all dependent jobs have passed
# It symbolizes that all required Backend checks have succesfully passed (Or skipped)
# This step is the only required backend check
backend-required-check:
needs:
[
api-docs,
backend-test,
backend-migration-tests,
cli,
files-changed,
requirements,
migration,
relay,
symbolicator,
typing,
]
name: Backend
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
if: always()
runs-on: ubuntu-20.04
steps:
# If any jobs we depend on fail, we will fail since this is a required check
# NOTE: A timeout is considered a failure
- name: Check for failures
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1