Makefile 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. 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. fetch-release-registry:
  71. @echo "--> Fetching release registry"
  72. @echo "from sentry.utils.distutils import sync_registry; sync_registry()" | sentry exec
  73. run-acceptance:
  74. @echo "--> Running acceptance tests"
  75. pytest tests/acceptance --cov . --cov-report="xml:.artifacts/acceptance.coverage.xml"
  76. @echo ""
  77. test-cli: create-db
  78. @echo "--> Testing CLI"
  79. rm -rf test_cli
  80. mkdir test_cli
  81. cd test_cli && sentry init test_conf
  82. cd test_cli && sentry --config=test_conf help
  83. cd test_cli && sentry --config=test_conf upgrade --traceback --noinput
  84. cd test_cli && sentry --config=test_conf export
  85. rm -r test_cli
  86. @echo ""
  87. test-js-build: node-version-check
  88. @echo "--> Running type check"
  89. @yarn run tsc -p config/tsconfig.build.json
  90. @echo "--> Building static assets"
  91. @NODE_ENV=production yarn webpack-profile > .artifacts/webpack-stats.json
  92. test-js: node-version-check
  93. @echo "--> Running JavaScript tests"
  94. @yarn run test
  95. @echo ""
  96. test-js-ci: node-version-check
  97. @echo "--> Running CI JavaScript tests"
  98. @yarn run test-ci
  99. @echo ""
  100. # COV_ARGS controls extra args passed to pytest to generate covereage
  101. # It's used in test-python-ci. Typically generated an XML coverage file
  102. # Except in .github/workflows/codecov_per_test_coverage.yml
  103. # When it's dynamically changed to include --cov-context=test flag
  104. # See that workflow for more info
  105. COV_ARGS = --cov-report="xml:.artifacts/python.coverage.xml"
  106. test-python-ci: create-db
  107. @echo "--> Running CI Python tests"
  108. pytest \
  109. tests \
  110. --ignore tests/acceptance \
  111. --ignore tests/apidocs \
  112. --ignore tests/js \
  113. --ignore tests/tools \
  114. --cov . $(COV_ARGS)
  115. @echo ""
  116. # it's not possible to change settings.DATABASE after django startup, so
  117. # unfortunately these tests must be run in a separate pytest process. References:
  118. # * https://docs.djangoproject.com/en/4.2/topics/testing/tools/#overriding-settings
  119. # * https://code.djangoproject.com/ticket/19031
  120. # * https://github.com/pombredanne/django-database-constraints/blob/master/runtests.py#L61-L77
  121. test-monolith-dbs: create-db
  122. @echo "--> Running CI Python tests (SENTRY_USE_MONOLITH_DBS=1)"
  123. SENTRY_LEGACY_TEST_SUITE=1 \
  124. SENTRY_USE_MONOLITH_DBS=1 \
  125. pytest \
  126. tests/sentry/backup/test_exhaustive.py \
  127. tests/sentry/backup/test_exports.py \
  128. tests/sentry/backup/test_imports.py \
  129. tests/sentry/backup/test_releases.py \
  130. tests/sentry/runner/commands/test_backup.py \
  131. --cov . \
  132. --cov-report="xml:.artifacts/python.monolith-dbs.coverage.xml" \
  133. ;
  134. @echo ""
  135. test-tools:
  136. @echo "--> Running tools tests"
  137. pytest -c /dev/null --confcutdir tests/tools tests/tools -vv --cov=tools --cov=tests/tools --cov-report="xml:.artifacts/tools.coverage.xml"
  138. @echo ""
  139. # JavaScript relay tests are meant to be run within Symbolicator test suite, as they are parametrized to verify both processing pipelines during migration process.
  140. # Running Locally: Run `sentry devservices up kafka` before starting these tests
  141. test-symbolicator: create-db
  142. @echo "--> Running symbolicator tests"
  143. pytest tests/symbolicator -vv --cov . --cov-report="xml:.artifacts/symbolicator.coverage.xml"
  144. pytest tests/relay_integration/lang/javascript/ -vv -m symbolicator
  145. @echo ""
  146. test-acceptance: node-version-check
  147. @echo "--> Building static assets"
  148. @$(WEBPACK)
  149. make run-acceptance
  150. # XXX: this is called by `getsentry/relay`
  151. test-relay-integration:
  152. @echo "--> Running Relay integration tests"
  153. pytest \
  154. tests/relay_integration \
  155. tests/sentry/ingest/ingest_consumer/test_ingest_consumer_kafka.py \
  156. -vv --cov . --cov-report="xml:.artifacts/relay.coverage.xml"
  157. @echo ""
  158. test-api-docs: build-api-docs
  159. yarn run validate-api-examples
  160. pytest tests/apidocs
  161. @echo ""
  162. review-python-snapshots:
  163. @cargo insta --version &> /dev/null || cargo install cargo-insta
  164. @cargo insta review --workspace-root `pwd` -e pysnap
  165. accept-python-snapshots:
  166. @cargo insta --version &> /dev/null || cargo install cargo-insta
  167. @cargo insta accept --workspace-root `pwd` -e pysnap
  168. reject-python-snapshots:
  169. @cargo insta --version &> /dev/null || cargo install cargo-insta
  170. @cargo insta reject --workspace-root `pwd` -e pysnap
  171. lint-js:
  172. @echo "--> Linting javascript"
  173. bin/lint --js --parseable
  174. @echo ""
  175. .PHONY: build