Makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 -q
  9. WEBPACK = NODE_ENV=production ./node_modules/.bin/webpack
  10. test: develop lint test-js test-python test-cli
  11. develop: setup-git develop-only
  12. # Used by https://github.com/getsentry/sentry-docs/blob/master/bin/extract-docs
  13. develop-only: update-submodules install-system-pkgs install-yarn-pkgs install-sentry-dev
  14. build: locale
  15. dev-docs:
  16. $(PIP) install -r doc-requirements.txt
  17. reset-db:
  18. @echo "--> Dropping existing 'sentry' database"
  19. dropdb sentry || true
  20. @echo "--> Creating 'sentry' database"
  21. createdb -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. cd .git/hooks && ln -sf ../../config/hooks/* ./
  38. @echo ""
  39. update-submodules:
  40. @echo "--> Updating git submodules"
  41. git submodule init
  42. git submodule update
  43. @echo ""
  44. install-system-pkgs:
  45. @echo "--> Installing system packages (from Brewfile)"
  46. @command -v brew 2>&1 > /dev/null && brew bundle || (echo 'WARNING: homebrew not found or brew bundle failed - skipping system dependencies.')
  47. install-yarn-pkgs:
  48. @echo "--> Installing Yarn packages (for development)"
  49. @command -v yarn 2>&1 > /dev/null || (echo 'yarn not found. Please install it before proceeding.'; exit 1)
  50. # Use NODE_ENV=development so that yarn installs both dependencies + devDependencies
  51. NODE_ENV=development yarn install --pure-lockfile
  52. install-sentry-dev:
  53. @echo "--> Installing Sentry (for development)"
  54. $(PIP) install -e ".[dev,tests,optional]"
  55. build-js-po:
  56. mkdir -p build
  57. SENTRY_EXTRACT_TRANSLATIONS=1 $(WEBPACK)
  58. locale: build-js-po
  59. cd src/sentry && sentry django makemessages -i static -l en
  60. ./bin/merge-catalogs en
  61. ./bin/find-good-catalogs src/sentry/locale/catalogs.json
  62. cd src/sentry && sentry django compilemessages
  63. update-transifex: build-js-po
  64. pip install -q transifex-client
  65. cd src/sentry && sentry django makemessages -i static -l en
  66. ./bin/merge-catalogs en
  67. tx push -s
  68. tx pull -a
  69. ./bin/find-good-catalogs src/sentry/locale/catalogs.json
  70. cd src/sentry && sentry django compilemessages
  71. build-platform-assets:
  72. @echo "--> Building platform assets"
  73. sentry init
  74. @echo "from sentry.utils.integrationdocs import sync_docs; sync_docs(quiet=True)" | sentry exec
  75. test-cli:
  76. @echo "--> Testing CLI"
  77. rm -rf test_cli
  78. mkdir test_cli
  79. cd test_cli && sentry init test_conf > /dev/null
  80. cd test_cli && sentry --config=test_conf upgrade --traceback --noinput > /dev/null
  81. cd test_cli && sentry --config=test_conf help 2>&1 | grep start > /dev/null
  82. rm -r test_cli
  83. @echo ""
  84. test-js:
  85. @echo "--> Building static assets"
  86. @$(WEBPACK) --profile --json > webpack-stats.json
  87. @echo "--> Running JavaScript tests"
  88. @npm run test-ci
  89. @echo ""
  90. # builds and creates percy snapshots
  91. test-styleguide:
  92. @echo "--> Building and snapshotting styleguide"
  93. @npm run snapshot
  94. @echo ""
  95. test-python: build-platform-assets
  96. @echo "--> Running Python tests"
  97. py.test tests/integration tests/sentry --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" || exit 1
  98. @echo ""
  99. test-network:
  100. @echo "--> Building platform assets"
  101. sentry init
  102. @echo "from sentry.utils.integrationdocs import sync_docs; sync_docs(quiet=True)" | sentry exec
  103. @echo "--> Running network tests"
  104. py.test tests/network --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml"
  105. @echo ""
  106. test-snuba:
  107. @echo "--> Running snuba tests"
  108. py.test tests/snuba --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml"
  109. @echo ""
  110. test-acceptance: build-platform-assets
  111. @echo "--> Building static assets"
  112. @$(WEBPACK) --display errors-only
  113. @echo "--> Running acceptance tests"
  114. py.test tests/acceptance --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" --html="pytest.html"
  115. @echo ""
  116. lint: lint-python lint-js
  117. lint-python:
  118. @echo "--> Linting python"
  119. bash -eo pipefail -c "bin/lint --python --parseable | tee flake8.pycodestyle.log"
  120. @echo ""
  121. lint-js:
  122. @echo "--> Linting javascript"
  123. bin/lint --js --parseable
  124. @echo ""
  125. scan-python:
  126. @echo "--> Running Python vulnerability scanner"
  127. python -m pip install -q safety
  128. bin/scan
  129. @echo ""
  130. publish:
  131. python setup.py sdist bdist_wheel upload
  132. ############################
  133. # Halt, Travis stuff below #
  134. ############################
  135. travis-noop:
  136. @echo "nothing to do here."
  137. # Lint steps
  138. travis-lint-sqlite: lint-python
  139. travis-lint-postgres: lint-python
  140. travis-lint-mysql: lint-python
  141. travis-lint-acceptance: travis-noop
  142. travis-lint-network: lint-python
  143. travis-lint-snuba: lint-python
  144. travis-lint-js: lint-js
  145. travis-lint-cli: travis-noop
  146. travis-lint-dist: travis-noop
  147. # Test steps
  148. travis-test-sqlite: test-python
  149. travis-test-postgres: test-python
  150. travis-test-mysql: test-python
  151. travis-test-acceptance: test-acceptance
  152. travis-test-network: test-network
  153. travis-test-snuba: test-snuba
  154. travis-test-js: test-js
  155. travis-test-cli: test-cli
  156. travis-test-dist:
  157. SENTRY_BUILD=$(TRAVIS_COMMIT) SENTRY_LIGHT_BUILD=0 python setup.py sdist bdist_wheel
  158. @ls -lh dist/
  159. # Scan steps
  160. travis-scan-sqlite: scan-python
  161. travis-scan-postgres: scan-python
  162. travis-scan-mysql: scan-python
  163. travis-scan-acceptance: travis-noop
  164. travis-scan-network: travis-noop
  165. travis-scan-snuba: scan-python
  166. travis-scan-js: travis-noop
  167. travis-scan-cli: travis-noop
  168. travis-scan-dist: travis-noop
  169. .PHONY: all develop develop-only build dev-docs test testloop reset-db clean setup-git update-submodules install-system-pkgs install-yarn-pkgs install-sentry install-sentry-dev build-js-po locale update-transifex build-platform-assets test-cli test-js test-styleguide test-python test-network test-snuba test-acceptance lint lint-python lint-js scan-python coverage publish extract-api-docs travis-noop travis-setup-cassandra travis-lint-sqlite travis-lint-postgres travis-lint-mysql travis-lint-acceptance travis-lint-network travis-lint-snuba travis-lint-js travis-lint-cli travis-lint-dist travis-test-sqlite travis-test-postgres travis-test-mysql travis-test-acceptance travis-test-network travis-test-snuba travis-test-js travis-test-cli travis-test-dist travis-scan-sqlite travis-scan-postgres travis-scan-mysql travis-scan-acceptance travis-scan-network travis-scan-snuba travis-scan-js travis-scan-cli travis-scan-dist