Makefile 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. PIP := python -m pip --disable-pip-version-check
  2. WEBPACK := NODE_ENV=production ./bin/yarn webpack
  3. YARN := ./bin/yarn
  4. bootstrap: develop init-config run-dependent-services create-db apply-migrations
  5. develop: ensure-pinned-pip setup-git install-yarn-pkgs install-sentry-dev
  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: ensure-venv
  17. sentry init --dev
  18. run-dependent-services: ensure-venv
  19. sentry devservices up
  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: ensure-venv
  35. @echo "--> Applying migrations"
  36. sentry upgrade
  37. reset-db: drop-db create-db apply-migrations
  38. ensure-venv:
  39. @./scripts/ensure-venv.sh
  40. ensure-pinned-pip: ensure-venv
  41. $(PIP) install --no-cache-dir --upgrade "pip>=20.0.2"
  42. setup-git-config:
  43. @git config --local branch.autosetuprebase always
  44. @git config --local core.ignorecase false
  45. @git config --local blame.ignoreRevsFile .git-blame-ignore-revs
  46. setup-git: ensure-venv setup-git-config
  47. @echo "--> Installing git hooks"
  48. cd .git/hooks && ln -sf ../../config/hooks/* ./
  49. @# XXX(joshuarli): virtualenv >= 20 doesn't work with the version of six we have pinned for sentry.
  50. @# Since pre-commit is installed in the venv, it will install virtualenv in the venv as well.
  51. @# We need to tell pre-commit to install an older virtualenv,
  52. @# And we need to tell virtualenv to install an older six, so that sentry installation
  53. @# won't complain about a newer six being present.
  54. @# So, this six pin here needs to be synced with requirements-base.txt.
  55. $(PIP) install "pre-commit==1.18.2" "virtualenv>=16.7,<20" "six>=1.10.0,<1.11.0"
  56. pre-commit install --install-hooks
  57. @echo ""
  58. node-version-check:
  59. @test "$$(node -v)" = v"$$(cat .nvmrc)" || (echo 'node version does not match .nvmrc. Recommended to use https://github.com/volta-cli/volta'; exit 1)
  60. install-yarn-pkgs: node-version-check
  61. @echo "--> Installing Yarn packages (for development)"
  62. # Use NODE_ENV=development so that yarn installs both dependencies + devDependencies
  63. NODE_ENV=development $(YARN) install --frozen-lockfile
  64. # A common problem is with node packages not existing in `node_modules` even though `yarn install`
  65. # says everything is up to date. Even though `yarn install` is run already, it doesn't take into
  66. # account the state of the current filesystem (it only checks .yarn-integrity).
  67. # Add an additional check against `node_modules`
  68. $(YARN) check --verify-tree || $(YARN) install --check-files
  69. install-sentry-dev: ensure-pinned-pip
  70. @echo "--> Installing Sentry (for development)"
  71. # SENTRY_LIGHT_BUILD=1 disables webpacking during setup.py.
  72. # Webpacked assets are only necessary for devserver (which does it lazily anyways)
  73. # and acceptance tests, which webpack automatically if run.
  74. SENTRY_LIGHT_BUILD=1 $(PIP) install -e ".[dev]"
  75. build-js-po: node-version-check
  76. mkdir -p build
  77. SENTRY_EXTRACT_TRANSLATIONS=1 $(WEBPACK)
  78. build: locale
  79. merge-locale-catalogs: build-js-po
  80. $(PIP) install Babel
  81. cd src/sentry && sentry django makemessages -i static -l en
  82. ./bin/merge-catalogs en
  83. compile-locale:
  84. ./bin/find-good-catalogs src/sentry/locale/catalogs.json
  85. cd src/sentry && sentry django compilemessages
  86. locale: merge-locale-catalogs compile-locale
  87. sync-transifex: merge-locale-catalogs
  88. $(PIP) install transifex-client
  89. tx push -s
  90. tx pull -a
  91. update-transifex: sync-transifex compile-locale
  92. build-platform-assets:
  93. @echo "--> Building platform assets"
  94. @echo "from sentry.utils.integrationdocs import sync_docs; sync_docs(quiet=True)" | sentry exec
  95. fetch-release-registry:
  96. @echo "--> Fetching release registry"
  97. @echo "from sentry.utils.distutils import sync_registry; sync_registry()" | sentry exec
  98. run-acceptance:
  99. @echo "--> Running acceptance tests"
  100. ifndef TEST_GROUP
  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. else
  103. py.test tests/acceptance -m group_$(TEST_GROUP) --cov . --cov-report="xml:.artifacts/acceptance.coverage.xml" --junit-xml=".artifacts/acceptance.junit.xml" --html=".artifacts/acceptance.pytest.html" --self-contained-html
  104. endif
  105. @echo ""
  106. test-cli:
  107. @echo "--> Testing CLI"
  108. rm -rf test_cli
  109. mkdir test_cli
  110. cd test_cli && sentry init test_conf
  111. cd test_cli && sentry --config=test_conf help
  112. cd test_cli && sentry --config=test_conf upgrade --traceback --noinput
  113. cd test_cli && sentry --config=test_conf export
  114. rm -r test_cli
  115. @echo ""
  116. test-js-build: node-version-check
  117. @echo "--> Running type check"
  118. @$(YARN) run tsc
  119. @echo "--> Building static assets"
  120. @$(WEBPACK) --profile --json > .artifacts/webpack-stats.json
  121. test-js: node-version-check
  122. @echo "--> Running JavaScript tests"
  123. @$(YARN) run test
  124. @echo ""
  125. test-js-ci: node-version-check
  126. @echo "--> Running CI JavaScript tests"
  127. @$(YARN) run test-ci
  128. @echo ""
  129. # builds and creates percy snapshots
  130. test-styleguide:
  131. @echo "--> Building and snapshotting styleguide"
  132. @$(YARN) run snapshot
  133. @echo ""
  134. test-python:
  135. @echo "--> Running Python tests"
  136. py.test tests/integration tests/sentry
  137. test-python-ci:
  138. sentry init
  139. make build-platform-assets
  140. @echo "--> Running CI Python tests"
  141. ifndef TEST_GROUP
  142. py.test tests/integration tests/sentry --cov . --cov-report="xml:.artifacts/python.coverage.xml" --junit-xml=".artifacts/python.junit.xml" || exit 1
  143. else
  144. py.test tests/integration tests/sentry -m group_$(TEST_GROUP) --cov . --cov-report="xml:.artifacts/python.coverage.xml" --junit-xml=".artifacts/python.junit.xml" || exit 1
  145. endif
  146. @echo ""
  147. test-snuba:
  148. @echo "--> Running snuba tests"
  149. py.test tests/snuba tests/sentry/eventstream/kafka -vv --cov . --cov-report="xml:.artifacts/snuba.coverage.xml" --junit-xml=".artifacts/snuba.junit.xml"
  150. @echo ""
  151. test-symbolicator:
  152. @echo "--> Running symbolicator tests"
  153. py.test tests/symbolicator -vv --cov . --cov-report="xml:.artifacts/symbolicator.coverage.xml" --junit-xml=".artifacts/symbolicator.junit.xml"
  154. @echo ""
  155. test-acceptance: node-version-check
  156. sentry init
  157. @echo "--> Building static assets"
  158. @$(WEBPACK) --display errors-only
  159. make run-acceptance
  160. test-plugins:
  161. @echo "--> Building static assets"
  162. @$(WEBPACK) --display errors-only
  163. @echo "--> Running plugin tests"
  164. py.test tests/sentry_plugins -vv --cov . --cov-report="xml:.artifacts/plugins.coverage.xml" --junit-xml=".artifacts/plugins.junit.xml"
  165. @echo ""
  166. test-relay-integration:
  167. @echo "--> Running Relay integration tests"
  168. pytest tests/relay_integration -vv
  169. @echo ""
  170. review-python-snapshots:
  171. @cargo insta --version &> /dev/null || cargo install cargo-insta
  172. @cargo insta review --workspace-root `pwd` -e pysnap
  173. accept-python-snapshots:
  174. @cargo insta --version &> /dev/null || cargo install cargo-insta
  175. @cargo insta accept --workspace-root `pwd` -e pysnap
  176. reject-python-snapshots:
  177. @cargo insta --version &> /dev/null || cargo install cargo-insta
  178. @cargo insta reject --workspace-root `pwd` -e pysnap
  179. lint-js:
  180. @echo "--> Linting javascript"
  181. bin/lint --js --parseable
  182. @echo ""
  183. .PHONY: develop build reset-db clean setup-git node-version-check install-yarn-pkgs install-sentry-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
  184. ############################
  185. # Halt, Travis stuff below #
  186. ############################
  187. .PHONY: travis-noop
  188. travis-noop:
  189. @echo "nothing to do here."
  190. .PHONY: travis-test-lint-js
  191. travis-test-lint-js: lint-js
  192. .PHONY: travis-test-postgres travis-test-acceptance travis-test-snuba travis-test-symbolicator travis-test-js travis-test-js-build
  193. .PHONY: travis-test-cli travis-test-relay-integration
  194. travis-test-postgres: test-python-ci
  195. travis-test-acceptance: test-acceptance
  196. travis-test-snuba: test-snuba
  197. travis-test-symbolicator: test-symbolicator
  198. travis-test-js: test-js-ci
  199. travis-test-js-build: test-js-build
  200. travis-test-cli: test-cli
  201. travis-test-plugins: test-plugins
  202. travis-test-relay-integration: test-relay-integration