Makefile 8.2 KB

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