Makefile 6.9 KB

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