Makefile 6.6 KB

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