Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
332 lines (278 loc) · 11.3 KB
/
Copy pathMakefile
File metadata and controls
332 lines (278 loc) · 11.3 KB
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
.PHONY: all
all: develop
WEBPACK := pnpm run build-acceptance
freeze-requirements:
@uv lock
bootstrap:
@echo "devenv bootstrap is typically run on new machines."
@echo "you probably want to run devenv sync to bring the"
@echo "sentry dev environment up to date!"
.PHONY: init-config run-dependent-services build-platform-assets clean create-db drop-db apply-migrations reset-db
init-config:
sentry init --dev --no-clobber
run-dependent-services:
devservices up
build-platform-assets:
@echo "--> Building platform assets"
python3 -m sentry.build._integration_docs
@# make sure this didn't silently do nothing
@test -f src/sentry/integration-docs/android.json
clean:
@echo "--> Cleaning static cache"
rm -rf dist/* src/sentry/static/sentry/dist/*
@echo "--> Cleaning integration docs cache"
rm -rf src/sentry/integration-docs
@echo "--> Cleaning pyc files"
find . -name "*.pyc" -delete
@echo "--> Cleaning python build artifacts"
rm -rf build/ dist/ src/sentry/assets.json
create-db:
@python3 -m tools.dev_db create
drop-db:
@python3 -m tools.dev_db drop
apply-migrations:
@python3 -m tools.dev_db migrate
# One invocation keeps drop, migrate and createuser ordered under `make -j`.
reset-db:
@python3 -m tools.dev_db reset
develop \
install-js-dev \
install-py-dev :
@make devenv-sync
# This is to ensure devenv sync's only called once if the above
# macros are combined e.g. `make install-js-dev install-py-dev`
.PHONY: devenv-sync
devenv-sync:
devenv sync
build-js-po:
mkdir -p build
pnpm run build-js-po
build-spectacular-docs:
@echo "--> Building drf-spectacular openapi spec (combines with deprecated docs)"
@OPENAPIGENERATE=1 sentry django spectacular --file tests/apidocs/openapi-spectacular.json --format openapi-json --validate --fail-on-warn
build-deprecated-docs:
@echo "--> Building deprecated openapi spec from json files"
pnpm run build-deprecated-docs
build-api-docs: build-deprecated-docs build-spectacular-docs
@echo "--> Dereference the json schema for ease of use"
pnpm run deref-api-docs
# Records the undocumented API responses from a test run with SENTRY_OPENAPI_RESPONSE_CHECK=report
# in tests/apidocs/openapi-response-baseline.json. Only the endpoint methods the run called change.
api-response-baseline:
@python3 -m tools.openapi_response_baseline $(ARGS)
# The internal RPC method schema, which CI's openapi-diff checks for breaking changes.
# It also ships with @sentry/api releases (static/packages/api) next to the API spec.
build-rpc-schema:
@mkdir -p .artifacts
sentry rpcschema --loglevel=WARNING > .artifacts/rpc_method_schema.json
# Opt-in private schema for local review; never included in the public docs build.
build-investigation-api-docs: build-deprecated-docs
@mkdir -p .artifacts/investigation-api-docs
@OPENAPIGENERATE=1 sentry django spectacular --custom-settings sentry.investigations.apidocs.PRIVATE_SCHEMA_SETTINGS --file .artifacts/investigation-api-docs/openapi.json --format openapi-json --validate --fail-on-warn
pnpm exec node api-docs/index.ts .artifacts/investigation-api-docs/openapi.json .artifacts/investigation-api-docs/openapi-derefed.json
pnpm --filter @sentry-internal/api-docs exec openapi-examples-validator ../.artifacts/investigation-api-docs/openapi-derefed.json --no-additional-properties
api-owner-map:
@echo "--> Generating API endpoint owner map"
@mkdir -p .artifacts
@sentry django api_endpoint_owners --output .artifacts/api-endpoint-owners.json
# Writes api_exceptions/exceptions.json, or updates it with ARGS="--files example_file" (only those files) or ARGS="--update" (every file).
# Updates keep each entry's status, reason and first_seen. (note: needs the owner map from `make api-owner-map`)
api-baseline:
@echo "--> Generating the API exceptions baseline"
@python3 -m tools.api_guidelines.generate_baseline $(ARGS)
# Every team's API rule findings, read from api_exceptions/exceptions.json (`make api-baseline` writes it).
# Pass ARGS, i.e `make api-report-card ARGS="--team issues-feed"`, ARGS="--format markdown"
# or ARGS="--compare older-exceptions.json" for the new, fixed and changed-count entries since an older file
api-report-card:
@python3 -m tools.api_guidelines.report_card $(ARGS)
watch-api-docs:
@cd api-docs/ && node ./watch.ts
# Compares tests/apidocs/openapi-derefed.json (from build-api-docs) with the
# master spec where this branch started, the same way CI's openapi-diff does.
# Needs gh (logged in) and docker.
diff-api-docs:
@echo "--> diffing local api docs against the merge-base's spec"
.github/workflows/scripts/openapi-diff.sh baseline .artifacts/openapi-baseline
.github/workflows/scripts/openapi-diff.sh changelog .artifacts/openapi-baseline/openapi-derefed.json tests/apidocs/openapi-derefed.json
build: locale
merge-locale-catalogs: build-js-po
uv pip install Babel
cd src/sentry && sentry django makemessages -i static -l en
./bin/merge-catalogs en
compile-locale:
uv pip install Babel
./bin/find-good-catalogs src/sentry/locale/catalogs.json
cd src/sentry && sentry django compilemessages
install-transifex:
uv pip install transifex-client
push-transifex: merge-locale-catalogs install-transifex
tx push -s
pull-transifex: install-transifex
tx pull -a
# Update transifex with new strings that need to be translated
update-transifex: push-transifex
# Pulls new translations from transifex and compiles for usage
update-local-locales: pull-transifex compile-locale
build-chartcuterie-config:
@echo "--> Building chartcuterie config module"
pnpm run build-chartcuterie-config
# CI sets this to pytest-selected.py when it has test durations to balance
# shards with.
ACCEPTANCE_PYTEST ?= -m pytest
run-acceptance:
@echo "--> Running acceptance tests"
python3 -b $(ACCEPTANCE_PYTEST) tests/acceptance --reuse-db --json-report --json-report-file=".artifacts/pytest.acceptance.json" --json-report-omit=log --junit-xml=".artifacts/acceptance.junit.xml" -o junit_suite_name=acceptance
@echo ""
test-cli: create-db
@echo "--> Testing CLI"
rm -rf test_cli
mkdir test_cli
cd test_cli && sentry init test_conf
cd test_cli && sentry --config=test_conf help
cd test_cli && sentry --config=test_conf upgrade --traceback --noinput
cd test_cli && sentry --config=test_conf export --help
rm -r test_cli
@echo ""
test-js-build:
@echo "--> Running type check"
@pnpm run typecheck
@echo "--> Building static assets"
@NODE_ENV=production pnpm run build-profile > .artifacts/webpack-stats.json
test-js:
@echo "--> Running JavaScript tests"
@pnpm run test
@echo ""
test-js-ci:
@echo "--> Running CI JavaScript tests"
@pnpm run test-ci
@echo ""
test-python-ci:
@echo "--> Running CI Python tests"
python3 -b .github/workflows/scripts/pytest-selected.py \
tests \
--reuse-db \
--ignore tests/acceptance \
--ignore tests/apidocs \
--ignore tests/js \
--ignore tests/tools \
--json-report \
--json-report-file=".artifacts/pytest.json" \
--json-report-omit=log \
--junit-xml=.artifacts/pytest.junit.xml \
-o junit_suite_name=pytest
@echo ""
test-migrations-ci:
@echo "--> Running CI Python migration tests"
python3 -b -m pytest \
$$(find tests -type d -name migrations) \
-m migrations \
--migrations \
--reruns 0 \
--fail-slow=150s \
--reuse-db \
--json-report \
--json-report-file=".artifacts/pytest.json" \
--json-report-omit=log \
--junit-xml=.artifacts/pytest.junit.xml \
-o junit_suite_name=pytest
@echo ""
test-backend-ci-with-coverage:
@echo "--> Running CI Python tests with coverage"
python3 -b -m pytest \
tests \
--reuse-db \
--ignore tests/acceptance \
--ignore tests/apidocs \
--ignore tests/js \
--ignore tests/tools \
--cov . \
--cov-context=test \
--json-report \
--json-report-file=".artifacts/pytest.json" \
--json-report-omit=log \
--junit-xml=.artifacts/pytest.junit.xml \
-o junit_suite_name=pytest
@echo ""
test-selective:
@echo "--> Running selective tests based on branch changes"
python3 .github/workflows/scripts/selective-testing/fetch-coverage.py \
--output .cache/coverage.db
mkdir -p .cache && > .cache/selected-tests.txt
python3 .github/workflows/scripts/compute-sentry-selected-tests.py \
--coverage-db .cache/coverage.db \
--changed-files "$$(git diff --name-only $$(git merge-base origin/master HEAD))" \
--output .cache/selected-tests.txt
python3 .github/workflows/scripts/selective-testing/confirm-test-selection.py \
.cache/selected-tests.txt
SELECTED_TESTS_FILE=.cache/selected-tests.txt \
python3 -b .github/workflows/scripts/pytest-selected.py \
-n3 \
tests \
--reuse-db \
--ignore tests/acceptance \
--ignore tests/apidocs \
--ignore tests/js \
--ignore tests/tools \
--quiet
@echo ""
# it's not possible to change settings.DATABASE after django startup, so
# unfortunately these tests must be run in a separate pytest process. References:
# * https://docs.djangoproject.com/en/4.2/topics/testing/tools/#overriding-settings
# * https://code.djangoproject.com/ticket/19031
# * https://github.com/pombredanne/django-database-constraints/blob/master/runtests.py#L61-L77
test-monolith-dbs:
@echo "--> Running CI Python tests (SENTRY_USE_MONOLITH_DBS=1)"
SENTRY_LEGACY_TEST_SUITE=1 \
SENTRY_USE_MONOLITH_DBS=1 \
python3 -b -m pytest \
tests/sentry/backup/test_exhaustive.py \
tests/sentry/backup/test_exports.py \
tests/sentry/backup/test_imports.py \
tests/sentry/runner/commands/test_backup.py \
--reuse-db \
--json-report \
--json-report-file=".artifacts/pytest.monolith-dbs.json" \
--json-report-omit=log \
--junit-xml=.artifacts/monolith-dbs.junit.xml \
-o junit_suite_name=monolith-dbs \
;
@echo ""
test-tools:
@echo "--> Running tools tests"
@# bogus configuration to force vanilla pytest
python3 -b -m pytest -c setup.cfg --confcutdir tests/tools tests/tools .github/workflows/scripts --reuse-db -vv --junit-xml=.artifacts/tools.junit.xml -o junit_suite_name=tools
@echo ""
# JavaScript relay tests are meant to be run within Symbolicator test suite, as they are parametrized to verify both processing pipelines during migration process.
# Running Locally: Run `devservices up` before starting these tests
test-symbolicator:
@echo "--> Running symbolicator tests"
python3 -b -m pytest tests/symbolicator tests/relay_integration/lang/javascript/ tests/relay_integration/lang/java/ tests/sentry/ -m symbolicator --reuse-db -vv --junit-xml=.artifacts/symbolicator.junit.xml -o junit_suite_name=symbolicator
@echo ""
test-acceptance:
@echo "--> Building static assets"
@$(WEBPACK)
make run-acceptance
# XXX: this is called by `getsentry/relay`
test-relay-integration:
@echo "--> Running Relay integration tests"
python3 -b -m pytest \
tests/relay_integration \
tests/sentry/ingest/ingest_consumer/test_ingest_consumer_kafka.py \
--reuse-db \
-vv
@echo ""
validate-api-docs: build-api-docs build-investigation-api-docs
pnpm run validate-api-examples
test-api-docs: validate-api-docs
python3 -b -m pytest tests/apidocs --reuse-db
@echo ""
review-python-snapshots:
@cargo insta --version &> /dev/null || cargo install cargo-insta
@cargo insta review --workspace-root `pwd` -e pysnap
accept-python-snapshots:
@cargo insta --version &> /dev/null || cargo install cargo-insta
@cargo insta accept --workspace-root `pwd` -e pysnap
reject-python-snapshots:
@cargo insta --version &> /dev/null || cargo install cargo-insta
@cargo insta reject --workspace-root `pwd` -e pysnap
.PHONY: build