Makefile 6.9 KB

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