Makefile 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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: ensure-pinned-pip setup-git install-js-dev install-py-dev
  5. clean:
  6. @echo "--> Cleaning static cache"
  7. rm -rf dist/* static/dist/*
  8. @echo "--> Cleaning integration docs cache"
  9. rm -rf src/sentry/integration-docs
  10. @echo "--> Cleaning pyc files"
  11. find . -name "*.pyc" -delete
  12. @echo "--> Cleaning python build artifacts"
  13. rm -rf build/ dist/ src/sentry/assets.json
  14. @echo ""
  15. init-config: ensure-venv
  16. sentry init --dev
  17. run-dependent-services: ensure-venv
  18. sentry devservices up
  19. DROPDB := $(shell command -v dropdb 2> /dev/null)
  20. ifndef DROPDB
  21. DROPDB = docker exec sentry_postgres dropdb
  22. endif
  23. CREATEDB := $(shell command -v createdb 2> /dev/null)
  24. ifndef CREATEDB
  25. CREATEDB = docker exec sentry_postgres createdb
  26. endif
  27. drop-db:
  28. @echo "--> Dropping existing 'sentry' database"
  29. $(DROPDB) -h 127.0.0.1 -U postgres sentry || true
  30. create-db:
  31. @echo "--> Creating 'sentry' database"
  32. $(CREATEDB) -h 127.0.0.1 -U postgres -E utf-8 sentry || true
  33. apply-migrations: ensure-venv
  34. @echo "--> Applying migrations"
  35. sentry upgrade
  36. reset-db: drop-db create-db apply-migrations
  37. setup-pyenv:
  38. ./scripts/pyenv_setup.sh
  39. ensure-venv:
  40. ./scripts/ensure-venv.sh
  41. ensure-pinned-pip: ensure-venv upgrade-pip
  42. upgrade-pip:
  43. ./scripts/python.sh upgrade-pip
  44. setup-git-config:
  45. @git config --local branch.autosetuprebase always
  46. @git config --local core.ignorecase false
  47. @git config --local blame.ignoreRevsFile .git-blame-ignore-revs
  48. setup-git: ensure-venv setup-git-config
  49. @echo "--> Installing git hooks"
  50. mkdir -p .git/hooks && cd .git/hooks && ln -sf ../../config/hooks/* ./
  51. @python3 -c '' || (echo 'Please run `make setup-pyenv` to install the required Python 3 version.'; exit 1)
  52. $(PIP) install -r requirements-pre-commit.txt
  53. @pre-commit install --install-hooks
  54. @echo ""
  55. node-version-check:
  56. @# Checks to see if node's version matches the one specified in package.json for Volta.
  57. @node -pe "process.exit(Number(!(process.version == 'v' + require('./package.json').volta.node )))" || \
  58. (echo 'Unexpected node version. Recommended to use https://github.com/volta-cli/volta'; exit 1)
  59. install-js-dev: node-version-check
  60. @echo "--> Installing Yarn packages (for development)"
  61. # Use NODE_ENV=development so that yarn installs both dependencies + devDependencies
  62. NODE_ENV=development yarn install --frozen-lockfile
  63. # A common problem is with node packages not existing in `node_modules` even though `yarn install`
  64. # says everything is up to date. Even though `yarn install` is run already, it doesn't take into
  65. # account the state of the current filesystem (it only checks .yarn-integrity).
  66. # Add an additional check against `node_modules`
  67. yarn check --verify-tree || yarn install --check-files
  68. install-py-dev:
  69. ./scripts/python.sh install-py-dev
  70. build-js-po: node-version-check
  71. mkdir -p build
  72. SENTRY_EXTRACT_TRANSLATIONS=1 $(WEBPACK)
  73. build: locale
  74. merge-locale-catalogs: build-js-po
  75. $(PIP) install Babel
  76. cd src/sentry && sentry django makemessages -i static -l en
  77. ./bin/merge-catalogs en
  78. compile-locale:
  79. ./bin/find-good-catalogs src/sentry/locale/catalogs.json
  80. cd src/sentry && sentry django compilemessages
  81. locale: merge-locale-catalogs compile-locale
  82. sync-transifex: merge-locale-catalogs
  83. $(PIP) install transifex-client
  84. tx push -s
  85. tx pull -a
  86. update-transifex: sync-transifex compile-locale
  87. build-platform-assets:
  88. @echo "--> Building platform assets"
  89. @echo "from sentry.utils.integrationdocs import sync_docs; sync_docs(quiet=True)" | sentry exec
  90. fetch-release-registry:
  91. @echo "--> Fetching release registry"
  92. @echo "from sentry.utils.distutils import sync_registry; sync_registry()" | sentry exec
  93. run-acceptance:
  94. @echo "--> Running acceptance tests"
  95. pytest tests/acceptance --cov . --cov-report="xml:.artifacts/acceptance.coverage.xml" --junit-xml=".artifacts/acceptance.junit.xml"
  96. @echo ""
  97. test-cli:
  98. @echo "--> Testing CLI"
  99. rm -rf test_cli
  100. mkdir test_cli
  101. cd test_cli && sentry init test_conf
  102. cd test_cli && sentry --config=test_conf help
  103. cd test_cli && sentry --config=test_conf upgrade --traceback --noinput
  104. cd test_cli && sentry --config=test_conf export
  105. rm -r test_cli
  106. @echo ""
  107. test-js-build: node-version-check
  108. @echo "--> Running type check"
  109. @yarn run tsc -p config/tsconfig.build.json
  110. @echo "--> Building static assets"
  111. @NODE_ENV=production yarn webpack-profile > .artifacts/webpack-stats.json
  112. test-js: node-version-check
  113. @echo "--> Running JavaScript tests"
  114. @yarn run test
  115. @echo ""
  116. test-js-ci: node-version-check
  117. @echo "--> Running CI JavaScript tests"
  118. @yarn run test-ci
  119. @echo ""
  120. test-python:
  121. @echo "--> Running Python tests"
  122. # This gets called by getsentry
  123. pytest tests/integration tests/sentry
  124. test-python-ci:
  125. make build-platform-assets
  126. @echo "--> Running CI Python tests"
  127. pytest tests/integration tests/sentry --cov . --cov-report="xml:.artifacts/python.coverage.xml" --junit-xml=".artifacts/python.junit.xml" || exit 1
  128. @echo ""
  129. test-snuba:
  130. @echo "--> Running snuba tests"
  131. 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"
  132. @echo ""
  133. backend-typing:
  134. @echo "--> Running Python typing checks"
  135. mypy --strict --warn-unreachable --config-file mypy.ini
  136. @echo ""
  137. test-symbolicator:
  138. @echo "--> Running symbolicator tests"
  139. pytest tests/symbolicator -vv --cov . --cov-report="xml:.artifacts/symbolicator.coverage.xml" --junit-xml=".artifacts/symbolicator.junit.xml"
  140. @echo ""
  141. test-acceptance: node-version-check
  142. @echo "--> Building static assets"
  143. @$(WEBPACK)
  144. make run-acceptance
  145. test-plugins:
  146. @echo "--> Running plugin tests"
  147. pytest tests/sentry_plugins -vv --cov . --cov-report="xml:.artifacts/plugins.coverage.xml" --junit-xml=".artifacts/plugins.junit.xml" || exit 1
  148. @echo ""
  149. test-relay-integration:
  150. @echo "--> Running Relay integration tests"
  151. pytest tests/relay_integration -vv
  152. @echo ""
  153. test-api-docs:
  154. @echo "--> Generating testing api doc schema"
  155. yarn run build-derefed-docs
  156. @echo "--> Validating endpoints' examples against schemas"
  157. yarn run validate-api-examples
  158. pytest tests/apidocs/endpoints
  159. @echo ""
  160. review-python-snapshots:
  161. @cargo insta --version &> /dev/null || cargo install cargo-insta
  162. @cargo insta review --workspace-root `pwd` -e pysnap
  163. accept-python-snapshots:
  164. @cargo insta --version &> /dev/null || cargo install cargo-insta
  165. @cargo insta accept --workspace-root `pwd` -e pysnap
  166. reject-python-snapshots:
  167. @cargo insta --version &> /dev/null || cargo install cargo-insta
  168. @cargo insta reject --workspace-root `pwd` -e pysnap
  169. lint-js:
  170. @echo "--> Linting javascript"
  171. bin/lint --js --parseable
  172. @echo ""
  173. .PHONY: bootstrap \
  174. develop \
  175. clean \
  176. init-config \
  177. run-dependent-services \
  178. drop-db \
  179. create-db \
  180. apply-migrations \
  181. reset-db \
  182. setup-pyenv \
  183. ensure-venv \
  184. ensure-pinned-pip \
  185. upgrade-pip \
  186. setup-git-config \
  187. setup-git \
  188. node-version-check \
  189. install-js-dev \
  190. install-py-dev \
  191. build-js-po \
  192. build \
  193. merge-locale-catalogs \
  194. compile-locale \
  195. locale \
  196. sync-transifex \
  197. update-transifex \
  198. build-platform-assets \
  199. fetch-release-registry \
  200. run-acceptance \
  201. test-cli \
  202. test-js-build \
  203. test-js \
  204. test-js-ci \
  205. test-python \
  206. test-python-ci \
  207. test-snuba \
  208. test-symbolicator \
  209. test-acceptance \
  210. test-plugins \
  211. test-relay-integration \
  212. test-api-docs \
  213. review-python-snapshots \
  214. accept-python-snapshots \
  215. reject-python-snapshots \
  216. lint-js