Makefile 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. STATIC_DIR = src/sentry/static/sentry
  2. ifneq "$(wildcard /usr/local/opt/libxmlsec1/lib)" ""
  3. LDFLAGS += -L/usr/local/opt/libxmlsec1/lib
  4. endif
  5. ifneq "$(wildcard /usr/local/opt/openssl/lib)" ""
  6. LDFLAGS += -L/usr/local/opt/openssl/lib
  7. endif
  8. PIP = LDFLAGS="$(LDFLAGS)" pip
  9. WEBPACK = NODE_ENV=production ./node_modules/.bin/webpack
  10. YARN_VERSION = 1.13.0
  11. develop: setup-git ensure-venv develop-only
  12. develop-only: update-submodules install-system-pkgs install-yarn-pkgs install-sentry-dev
  13. test: develop lint test-js test-python test-cli
  14. ensure-venv:
  15. @./scripts/ensure-venv.sh
  16. build: locale
  17. reset-db:
  18. @echo "--> Dropping existing 'sentry' database"
  19. dropdb -h 127.0.0.1 -U postgres sentry || true
  20. @echo "--> Creating 'sentry' database"
  21. createdb -h 127.0.0.1 -U postgres -E utf-8 sentry
  22. @echo "--> Applying migrations"
  23. sentry upgrade
  24. clean:
  25. @echo "--> Cleaning static cache"
  26. rm -rf dist/* static/dist/*
  27. @echo "--> Cleaning integration docs cache"
  28. rm -rf src/sentry/integration-docs
  29. @echo "--> Cleaning pyc files"
  30. find . -name "*.pyc" -delete
  31. @echo "--> Cleaning python build artifacts"
  32. rm -rf build/ dist/ src/sentry/assets.json
  33. @echo ""
  34. setup-git:
  35. @echo "--> Installing git hooks"
  36. git config branch.autosetuprebase always
  37. git config core.ignorecase false
  38. cd .git/hooks && ln -sf ../../config/hooks/* ./
  39. pip install "pre-commit>=1.10.1,<1.11.0"
  40. pre-commit install
  41. @echo ""
  42. update-submodules:
  43. @echo "--> Updating git submodules"
  44. git submodule init
  45. git submodule update
  46. @echo ""
  47. node-version-check:
  48. @test "$$(node -v)" = v"$$(cat .nvmrc)" || (echo 'node version does not match .nvmrc. Recommended to use https://github.com/creationix/nvm'; exit 1)
  49. install-system-pkgs: node-version-check
  50. @echo "--> Installing system packages (from Brewfile)"
  51. @command -v brew 2>&1 > /dev/null && brew bundle || (echo 'WARNING: homebrew not found or brew bundle failed - skipping system dependencies.')
  52. @echo "--> Installing yarn $(YARN_VERSION) (via npm)"
  53. @notion --version 2>&1 > /dev/null || npm install -g "yarn@$(YARN_VERSION)"
  54. install-yarn-pkgs:
  55. @echo "--> Installing Yarn packages (for development)"
  56. @command -v yarn 2>&1 > /dev/null || (echo 'yarn not found. Please install it before proceeding.'; exit 1)
  57. # Use NODE_ENV=development so that yarn installs both dependencies + devDependencies
  58. NODE_ENV=development yarn install --pure-lockfile
  59. install-sentry-dev:
  60. @echo "--> Installing Sentry (for development)"
  61. $(PIP) install -e ".[dev,tests,optional]"
  62. build-js-po: node-version-check
  63. mkdir -p build
  64. SENTRY_EXTRACT_TRANSLATIONS=1 $(WEBPACK)
  65. locale: build-js-po
  66. cd src/sentry && sentry django makemessages -i static -l en
  67. ./bin/merge-catalogs en
  68. ./bin/find-good-catalogs src/sentry/locale/catalogs.json
  69. cd src/sentry && sentry django compilemessages
  70. update-transifex: build-js-po
  71. $(PIP) install transifex-client
  72. cd src/sentry && sentry django makemessages -i static -l en
  73. ./bin/merge-catalogs en
  74. tx push -s
  75. tx pull -a
  76. ./bin/find-good-catalogs src/sentry/locale/catalogs.json
  77. cd src/sentry && sentry django compilemessages
  78. build-platform-assets:
  79. @echo "--> Building platform assets"
  80. sentry init
  81. @echo "from sentry.utils.integrationdocs import sync_docs; sync_docs(quiet=True)" | sentry exec
  82. fetch-release-registry:
  83. @echo "--> Fetching release registry"
  84. sentry init
  85. @echo "from sentry.utils.distutils import sync_registry; sync_registry()" | sentry exec
  86. test-cli:
  87. @echo "--> Testing CLI"
  88. rm -rf test_cli
  89. mkdir test_cli
  90. cd test_cli && sentry init test_conf > /dev/null
  91. cd test_cli && sentry --config=test_conf upgrade --traceback --noinput > /dev/null
  92. cd test_cli && sentry --config=test_conf help 2>&1 | grep start > /dev/null
  93. rm -r test_cli
  94. @echo ""
  95. test-js: node-version-check
  96. @echo "--> Building static assets"
  97. @$(WEBPACK) --profile --json > .artifacts/webpack-stats.json
  98. @echo "--> Running JavaScript tests"
  99. @npm run test-ci
  100. @echo ""
  101. # builds and creates percy snapshots
  102. test-styleguide:
  103. @echo "--> Building and snapshotting styleguide"
  104. @npm run snapshot
  105. @echo ""
  106. test-python: build-platform-assets
  107. @echo "--> Running Python tests"
  108. py.test tests/integration tests/sentry --cov . --cov-report="xml:.artifacts/python.coverage.xml" --junit-xml=".artifacts/python.junit.xml" || exit 1
  109. @echo ""
  110. test-snuba:
  111. @echo "--> Running snuba tests"
  112. py.test tests/snuba tests/sentry/eventstream/kafka -vv --cov . --cov-report="xml:.artifacts/snuba.coverage.xml" --junit-xml=".artifacts/snuba.junit.xml"
  113. @echo ""
  114. test-acceptance: build-platform-assets node-version-check
  115. @echo "--> Building static assets"
  116. @$(WEBPACK) --display errors-only
  117. @echo "--> Running acceptance tests"
  118. py.test tests/acceptance --cov . --cov-report="xml:.artifacts/acceptance.coverage.xml" --junit-xml=".artifacts/acceptance.junit.xml" --html=".artifacts/acceptance.pytest.html"
  119. @echo ""
  120. lint: lint-python lint-js
  121. lint-python:
  122. @echo "--> Linting python"
  123. bash -eo pipefail -c "flake8 | tee .artifacts/flake8.pycodestyle.log"
  124. @echo ""
  125. review-python-snapshots:
  126. @cargo insta --version &> /dev/null || cargo install cargo-insta
  127. @cargo insta review --workspace-root `pwd` -e pysnap
  128. accept-python-snapshots:
  129. @cargo insta --version &> /dev/null || cargo install cargo-insta
  130. @cargo insta accept --workspace-root `pwd` -e pysnap
  131. reject-python-snapshots:
  132. @cargo insta --version &> /dev/null || cargo install cargo-insta
  133. @cargo insta reject --workspace-root `pwd` -e pysnap
  134. lint-js:
  135. @echo "--> Linting javascript"
  136. bin/lint --js --parseable
  137. @echo ""
  138. publish:
  139. python setup.py sdist bdist_wheel upload
  140. .PHONY: develop develop-only test build test reset-db clean setup-git update-submodules node-version-check install-system-pkgs install-yarn-pkgs install-sentry-dev build-js-po locale update-transifex build-platform-assets test-cli test-js test-styleguide test-python test-snuba test-acceptance lint lint-python lint-js publish
  141. ############################
  142. # Halt, Travis stuff below #
  143. ############################
  144. .PHONY: travis-noop
  145. travis-noop:
  146. @echo "nothing to do here."
  147. .PHONY: travis-lint-sqlite travis-lint-postgres travis-lint-mysql travis-lint-acceptance travis-lint-snuba travis-lint-js travis-lint-cli travis-lint-dist
  148. travis-lint-sqlite: lint-python
  149. travis-lint-postgres: lint-python
  150. travis-lint-mysql: lint-python
  151. travis-lint-acceptance: travis-noop
  152. travis-lint-snuba: lint-python
  153. travis-lint-js: lint-js
  154. travis-lint-cli: travis-noop
  155. travis-lint-dist: travis-noop
  156. .PHONY: travis-test-sqlite travis-test-postgres travis-test-mysql travis-test-acceptance travis-test-snuba travis-test-js travis-test-cli travis-test-dist
  157. travis-test-sqlite: test-python
  158. travis-test-postgres: test-python
  159. travis-test-mysql: test-python
  160. travis-test-acceptance: test-acceptance
  161. travis-test-snuba: test-snuba
  162. travis-test-js: test-js
  163. travis-test-cli: test-cli
  164. travis-test-dist:
  165. # NOTE: We quiet down output here to workaround an issue in travis that
  166. # causes the build to fail with a EAGAIN when writing a large amount of
  167. # data to STDOUT.
  168. # See: https://github.com/travis-ci/travis-ci/issues/4704
  169. SENTRY_BUILD=$(TRAVIS_COMMIT) SENTRY_LIGHT_BUILD=0 python setup.py -q sdist bdist_wheel
  170. @ls -lh dist/
  171. .PHONY: scan-python travis-scan-sqlite travis-scan-postgres travis-scan-mysql travis-scan-acceptance travis-scan-snuba travis-scan-js travis-scan-cli travis-scan-dist
  172. scan-python:
  173. @echo "--> Running Python vulnerability scanner"
  174. $(PIP) install safety
  175. bin/scan
  176. @echo ""
  177. travis-scan-sqlite: scan-python
  178. travis-scan-postgres: scan-python
  179. travis-scan-mysql: scan-python
  180. travis-scan-acceptance: travis-noop
  181. travis-scan-snuba: scan-python
  182. travis-scan-js: travis-noop
  183. travis-scan-cli: travis-noop
  184. travis-scan-dist: travis-noop