Makefile 6.5 KB

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