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