Makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. PIP := python -m pip --disable-pip-version-check
  2. WEBPACK := yarn build-acceptance
  3. bootstrap: develop init-config run-dependent-services create-db apply-migrations build-platform-assets
  4. develop:
  5. @./scripts/do.sh develop
  6. clean:
  7. @echo "--> Cleaning static cache"
  8. rm -rf dist/* static/dist/*
  9. @echo "--> Cleaning integration docs cache"
  10. rm -rf src/sentry/integration-docs
  11. @echo "--> Cleaning pyc files"
  12. find . -name "*.pyc" -delete
  13. @echo "--> Cleaning python build artifacts"
  14. rm -rf build/ dist/ src/sentry/assets.json
  15. @echo ""
  16. init-config:
  17. @./scripts/do.sh init-config
  18. run-dependent-services:
  19. @./scripts/do.sh run-dependent-services
  20. DROPDB := $(shell command -v dropdb 2> /dev/null)
  21. ifndef DROPDB
  22. DROPDB = docker exec sentry_postgres dropdb
  23. endif
  24. CREATEDB := $(shell command -v createdb 2> /dev/null)
  25. ifndef CREATEDB
  26. CREATEDB = docker exec sentry_postgres createdb
  27. endif
  28. drop-db:
  29. @echo "--> Dropping existing 'sentry' database"
  30. $(DROPDB) -h 127.0.0.1 -U postgres sentry || true
  31. create-db:
  32. @echo "--> Creating 'sentry' database"
  33. $(CREATEDB) -h 127.0.0.1 -U postgres -E utf-8 sentry || true
  34. apply-migrations:
  35. @./scripts/do.sh apply-migrations
  36. reset-db: drop-db create-db apply-migrations
  37. setup-pyenv:
  38. @./scripts/pyenv_setup.sh
  39. upgrade-pip:
  40. @SENTRY_NO_VENV_CHECK=1 ./scripts/do.sh upgrade-pip
  41. setup-git-config:
  42. @SENTRY_NO_VENV_CHECK=1 ./scripts/do.sh setup-git-config
  43. setup-git:
  44. @./scripts/do.sh setup-git
  45. node-version-check:
  46. @# Checks to see if node's version matches the one specified in package.json for Volta.
  47. @node -pe "process.exit(Number(!(process.version == 'v' + require('./package.json').volta.node )))" || \
  48. (echo 'Unexpected node version. Recommended to use https://github.com/volta-cli/volta'; exit 1)
  49. install-js-dev: node-version-check
  50. @./scripts/do.sh install-js-dev
  51. install-py-dev:
  52. @./scripts/do.sh install-py-dev
  53. build-js-po: node-version-check
  54. mkdir -p build
  55. SENTRY_EXTRACT_TRANSLATIONS=1 $(WEBPACK)
  56. build: locale
  57. merge-locale-catalogs: build-js-po
  58. $(PIP) install Babel
  59. cd src/sentry && sentry django makemessages -i static -l en
  60. ./bin/merge-catalogs en
  61. compile-locale:
  62. ./bin/find-good-catalogs src/sentry/locale/catalogs.json
  63. cd src/sentry && sentry django compilemessages
  64. locale: merge-locale-catalogs compile-locale
  65. sync-transifex: merge-locale-catalogs
  66. $(PIP) install transifex-client
  67. tx push -s
  68. tx pull -a
  69. update-transifex: sync-transifex compile-locale
  70. build-platform-assets:
  71. @echo "--> Building platform assets"
  72. @echo "from sentry.utils.integrationdocs import sync_docs; sync_docs(quiet=True)" | sentry exec
  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" --junit-xml=".artifacts/acceptance.junit.xml"
  79. @echo ""
  80. test-cli:
  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:
  104. @echo "--> Running Python tests"
  105. # This gets called by getsentry
  106. pytest tests/integration tests/sentry
  107. test-python-ci:
  108. make build-platform-assets
  109. @echo "--> Running CI Python tests"
  110. pytest tests/integration tests/sentry --cov . --cov-report="xml:.artifacts/python.coverage.xml" --junit-xml=".artifacts/python.junit.xml" || exit 1
  111. @echo ""
  112. test-snuba:
  113. @echo "--> Running snuba tests"
  114. pytest tests/snuba tests/sentry/eventstream/kafka tests/sentry/snuba/test_discover.py -vv --cov . --cov-report="xml:.artifacts/snuba.coverage.xml" --junit-xml=".artifacts/snuba.junit.xml"
  115. @echo ""
  116. backend-typing:
  117. @echo "--> Running Python typing checks"
  118. mypy --strict --warn-unreachable --config-file mypy.ini
  119. @echo ""
  120. test-symbolicator:
  121. @echo "--> Running symbolicator tests"
  122. pytest tests/symbolicator -vv --cov . --cov-report="xml:.artifacts/symbolicator.coverage.xml" --junit-xml=".artifacts/symbolicator.junit.xml"
  123. @echo ""
  124. test-acceptance: node-version-check
  125. @echo "--> Building static assets"
  126. @$(WEBPACK)
  127. make run-acceptance
  128. test-plugins:
  129. @echo "--> Running plugin tests"
  130. pytest tests/sentry_plugins -vv --cov . --cov-report="xml:.artifacts/plugins.coverage.xml" --junit-xml=".artifacts/plugins.junit.xml" || exit 1
  131. @echo ""
  132. test-relay-integration:
  133. @echo "--> Running Relay integration tests"
  134. pytest tests/relay_integration -vv
  135. @echo ""
  136. test-api-docs:
  137. @echo "--> Generating testing api doc schema"
  138. yarn run build-derefed-docs
  139. @echo "--> Validating endpoints' examples against schemas"
  140. yarn run validate-api-examples
  141. pytest tests/apidocs/endpoints
  142. @echo ""
  143. review-python-snapshots:
  144. @cargo insta --version &> /dev/null || cargo install cargo-insta
  145. @cargo insta review --workspace-root `pwd` -e pysnap
  146. accept-python-snapshots:
  147. @cargo insta --version &> /dev/null || cargo install cargo-insta
  148. @cargo insta accept --workspace-root `pwd` -e pysnap
  149. reject-python-snapshots:
  150. @cargo insta --version &> /dev/null || cargo install cargo-insta
  151. @cargo insta reject --workspace-root `pwd` -e pysnap
  152. lint-js:
  153. @echo "--> Linting javascript"
  154. bin/lint --js --parseable
  155. @echo ""
  156. .PHONY: bootstrap \
  157. develop \
  158. clean \
  159. init-config \
  160. run-dependent-services \
  161. drop-db \
  162. create-db \
  163. apply-migrations \
  164. reset-db \
  165. setup-pyenv \
  166. setup-git-config \
  167. setup-git \
  168. node-version-check \
  169. install-js-dev \
  170. install-py-dev \
  171. build-js-po \
  172. build \
  173. merge-locale-catalogs \
  174. compile-locale \
  175. locale \
  176. sync-transifex \
  177. update-transifex \
  178. build-platform-assets \
  179. fetch-release-registry \
  180. run-acceptance \
  181. test-cli \
  182. test-js-build \
  183. test-js \
  184. test-js-ci \
  185. test-python \
  186. test-python-ci \
  187. test-snuba \
  188. test-symbolicator \
  189. test-acceptance \
  190. test-plugins \
  191. test-relay-integration \
  192. test-api-docs \
  193. review-python-snapshots \
  194. accept-python-snapshots \
  195. reject-python-snapshots \
  196. lint-js