Makefile 7.1 KB

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