Makefile 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. .PHONY: all
  2. all: develop
  3. PIP := python -m pip --disable-pip-version-check
  4. WEBPACK := yarn build-acceptance
  5. POSTGRES_CONTAINER := sentry_postgres
  6. freeze-requirements:
  7. @python3 -S -m tools.freeze_requirements
  8. bootstrap:
  9. @echo "devenv bootstrap is typically run on new machines."
  10. @echo "you probably want to run devenv sync to bring the"
  11. @echo "sentry dev environment up to date!"
  12. build-platform-assets \
  13. clean \
  14. init-config \
  15. run-dependent-services \
  16. drop-db \
  17. create-db \
  18. apply-migrations \
  19. reset-db \
  20. node-version-check :
  21. @./scripts/do.sh $@
  22. develop \
  23. install-js-dev \
  24. install-py-dev :
  25. @make devenv-sync
  26. # This is to ensure devenv sync's only called once if the above
  27. # macros are combined e.g. `make install-js-dev install-py-dev`
  28. .PHONY: devenv-sync
  29. devenv-sync:
  30. devenv sync
  31. build-js-po: node-version-check
  32. mkdir -p build
  33. rm -rf node_modules/.cache/babel-loader
  34. SENTRY_EXTRACT_TRANSLATIONS=1 $(WEBPACK)
  35. build-spectacular-docs:
  36. @echo "--> Building drf-spectacular openapi spec (combines with deprecated docs)"
  37. @OPENAPIGENERATE=1 sentry django spectacular --file tests/apidocs/openapi-spectacular.json --format openapi-json --validate --fail-on-warn
  38. build-deprecated-docs:
  39. @echo "--> Building deprecated openapi spec from json files"
  40. yarn build-deprecated-docs
  41. build-api-docs: build-deprecated-docs build-spectacular-docs
  42. @echo "--> Dereference the json schema for ease of use"
  43. yarn deref-api-docs
  44. watch-api-docs:
  45. @cd api-docs/ && yarn install
  46. @cd api-docs/ && ts-node ./watch.ts
  47. diff-api-docs:
  48. @echo "--> diffing local api docs against sentry-api-schema/openapi-derefed.json"
  49. yarn diff-docs
  50. build: locale
  51. merge-locale-catalogs: build-js-po
  52. $(PIP) install Babel
  53. cd src/sentry && sentry django makemessages -i static -l en
  54. ./bin/merge-catalogs en
  55. compile-locale:
  56. $(PIP) install Babel
  57. ./bin/find-good-catalogs src/sentry/locale/catalogs.json
  58. cd src/sentry && sentry django compilemessages
  59. install-transifex:
  60. $(PIP) install transifex-client
  61. push-transifex: merge-locale-catalogs install-transifex
  62. tx push -s
  63. pull-transifex: install-transifex
  64. tx pull -a
  65. # Update transifex with new strings that need to be translated
  66. update-transifex: push-transifex
  67. # Pulls new translations from transifex and compiles for usage
  68. update-local-locales: pull-transifex compile-locale
  69. build-chartcuterie-config:
  70. @echo "--> Building chartcuterie config module"
  71. yarn build-chartcuterie-config
  72. run-acceptance:
  73. @echo "--> Running acceptance tests"
  74. python3 -b -m pytest tests/acceptance --cov . --cov-report="xml:.artifacts/acceptance.coverage.xml" --json-report --json-report-file=".artifacts/pytest.acceptance.json" --json-report-omit=log --junit-xml=".artifacts/acceptance.junit.xml" -o junit_suite_name=acceptance
  75. @echo ""
  76. test-cli: create-db
  77. @echo "--> Testing CLI"
  78. rm -rf test_cli
  79. mkdir test_cli
  80. cd test_cli && sentry init test_conf
  81. cd test_cli && sentry --config=test_conf help
  82. cd test_cli && sentry --config=test_conf upgrade --traceback --noinput
  83. cd test_cli && sentry --config=test_conf export
  84. rm -r test_cli
  85. @echo ""
  86. test-js-build: node-version-check
  87. @echo "--> Running type check"
  88. @yarn run tsc -p config/tsconfig.build.json
  89. @echo "--> Building static assets"
  90. @NODE_ENV=production yarn webpack-profile > .artifacts/webpack-stats.json
  91. test-js: node-version-check
  92. @echo "--> Running JavaScript tests"
  93. @yarn run test
  94. @echo ""
  95. test-js-ci: node-version-check
  96. @echo "--> Running CI JavaScript tests"
  97. @yarn run test-ci
  98. @echo ""
  99. # COV_ARGS controls extra args passed to pytest to generate covereage
  100. # It's used in test-python-ci. Typically generated an XML coverage file
  101. # Except in .github/workflows/codecov_per_test_coverage.yml
  102. # When it's dynamically changed to include --cov-context=test flag
  103. # See that workflow for more info
  104. COV_ARGS = --cov-report="xml:.artifacts/python.coverage.xml"
  105. test-python-ci:
  106. @echo "--> Running CI Python tests"
  107. python3 -b -m pytest \
  108. tests \
  109. --ignore tests/acceptance \
  110. --ignore tests/apidocs \
  111. --ignore tests/js \
  112. --ignore tests/tools \
  113. --cov . $(COV_ARGS) \
  114. --json-report \
  115. --json-report-file=".artifacts/pytest.json" \
  116. --json-report-omit=log \
  117. --junit-xml=.artifacts/pytest.junit.xml \
  118. -o junit_suite_name=pytest
  119. @echo ""
  120. # it's not possible to change settings.DATABASE after django startup, so
  121. # unfortunately these tests must be run in a separate pytest process. References:
  122. # * https://docs.djangoproject.com/en/4.2/topics/testing/tools/#overriding-settings
  123. # * https://code.djangoproject.com/ticket/19031
  124. # * https://github.com/pombredanne/django-database-constraints/blob/master/runtests.py#L61-L77
  125. test-monolith-dbs:
  126. @echo "--> Running CI Python tests (SENTRY_USE_MONOLITH_DBS=1)"
  127. SENTRY_LEGACY_TEST_SUITE=1 \
  128. SENTRY_USE_MONOLITH_DBS=1 \
  129. python3 -b -m pytest \
  130. tests/sentry/backup/test_exhaustive.py \
  131. tests/sentry/backup/test_exports.py \
  132. tests/sentry/backup/test_imports.py \
  133. tests/sentry/backup/test_releases.py \
  134. tests/sentry/runner/commands/test_backup.py \
  135. --cov . \
  136. --cov-report="xml:.artifacts/python.monolith-dbs.coverage.xml" \
  137. --json-report \
  138. --json-report-file=".artifacts/pytest.monolith-dbs.json" \
  139. --json-report-omit=log \
  140. --junit-xml=.artifacts/monolith-dbs.junit.xml \
  141. -o junit_suite_name=monolith-dbs \
  142. ;
  143. @echo ""
  144. test-tools:
  145. @echo "--> Running tools tests"
  146. @# bogus configuration to force vanilla pytest
  147. python3 -b -m pytest -c setup.cfg --confcutdir tests/tools tests/tools -vv --cov=tools --cov=tests/tools --cov-report="xml:.artifacts/tools.coverage.xml" --junit-xml=.artifacts/tools.junit.xml -o junit_suite_name=tools
  148. @echo ""
  149. # JavaScript relay tests are meant to be run within Symbolicator test suite, as they are parametrized to verify both processing pipelines during migration process.
  150. # Running Locally: Run `sentry devservices up kafka` before starting these tests
  151. test-symbolicator:
  152. @echo "--> Running symbolicator tests"
  153. python3 -b -m pytest tests/symbolicator -vv --cov . --cov-report="xml:.artifacts/symbolicator.coverage.xml" --junit-xml=.artifacts/symbolicator.junit.xml -o junit_suite_name=symbolicator
  154. python3 -b -m pytest tests/relay_integration/lang/javascript/ -vv -m symbolicator
  155. python3 -b -m pytest tests/relay_integration/lang/java/ -vv -m symbolicator
  156. @echo ""
  157. test-acceptance: node-version-check
  158. @echo "--> Building static assets"
  159. @$(WEBPACK)
  160. make run-acceptance
  161. # XXX: this is called by `getsentry/relay`
  162. test-relay-integration:
  163. @echo "--> Running Relay integration tests"
  164. python3 -b -m pytest \
  165. tests/relay_integration \
  166. tests/sentry/ingest/ingest_consumer/test_ingest_consumer_kafka.py \
  167. -vv --cov . --cov-report="xml:.artifacts/relay.coverage.xml"
  168. @echo ""
  169. test-api-docs: build-api-docs
  170. yarn run validate-api-examples
  171. python3 -b -m pytest tests/apidocs
  172. @echo ""
  173. review-python-snapshots:
  174. @cargo insta --version &> /dev/null || cargo install cargo-insta
  175. @cargo insta review --workspace-root `pwd` -e pysnap
  176. accept-python-snapshots:
  177. @cargo insta --version &> /dev/null || cargo install cargo-insta
  178. @cargo insta accept --workspace-root `pwd` -e pysnap
  179. reject-python-snapshots:
  180. @cargo insta --version &> /dev/null || cargo install cargo-insta
  181. @cargo insta reject --workspace-root `pwd` -e pysnap
  182. .PHONY: build