Makefile 6.4 KB

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