Makefile 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 is used by https://github.com/getsentry/sentry-docs/blob/master/bin/extract-docs
  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. 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. 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. test-cli:
  80. @echo "--> Testing CLI"
  81. rm -rf test_cli
  82. mkdir test_cli
  83. cd test_cli && sentry init test_conf > /dev/null
  84. cd test_cli && sentry --config=test_conf upgrade --traceback --noinput > /dev/null
  85. cd test_cli && sentry --config=test_conf help 2>&1 | grep start > /dev/null
  86. rm -r test_cli
  87. @echo ""
  88. test-js: node-version-check
  89. @echo "--> Building static assets"
  90. @$(WEBPACK) --profile --json > webpack-stats.json
  91. @echo "--> Running JavaScript tests"
  92. @npm run test-ci
  93. @echo ""
  94. # builds and creates percy snapshots
  95. test-styleguide:
  96. @echo "--> Building and snapshotting styleguide"
  97. @npm run snapshot
  98. @echo ""
  99. test-python: build-platform-assets
  100. @echo "--> Running Python tests"
  101. py.test tests/integration tests/sentry --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" || exit 1
  102. @echo ""
  103. test-snuba:
  104. @echo "--> Running snuba tests"
  105. py.test tests/snuba -vv --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml"
  106. @echo ""
  107. test-acceptance: build-platform-assets node-version-check
  108. @echo "--> Building static assets"
  109. @$(WEBPACK) --display errors-only
  110. @echo "--> Running acceptance tests"
  111. py.test tests/acceptance --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" --html="pytest.html"
  112. @echo ""
  113. lint: lint-python lint-js
  114. lint-python:
  115. @echo "--> Linting python"
  116. bash -eo pipefail -c "bin/lint --python --parseable | tee flake8.pycodestyle.log"
  117. @echo ""
  118. lint-js:
  119. @echo "--> Linting javascript"
  120. bin/lint --js --parseable
  121. @echo ""
  122. publish:
  123. python setup.py sdist bdist_wheel upload
  124. .PHONY: develop develop-only test build dev-docs 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
  125. ############################
  126. # Halt, Travis stuff below #
  127. ############################
  128. .PHONY: travis-noop
  129. travis-noop:
  130. @echo "nothing to do here."
  131. .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
  132. travis-lint-sqlite: lint-python
  133. travis-lint-postgres: lint-python
  134. travis-lint-mysql: lint-python
  135. travis-lint-acceptance: travis-noop
  136. travis-lint-snuba: lint-python
  137. travis-lint-js: lint-js
  138. travis-lint-cli: travis-noop
  139. travis-lint-dist: travis-noop
  140. .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
  141. travis-test-sqlite: test-python
  142. travis-test-postgres: test-python
  143. travis-test-mysql: test-python
  144. travis-test-acceptance: test-acceptance
  145. travis-test-snuba: test-snuba
  146. travis-test-js: test-js
  147. travis-test-cli: test-cli
  148. travis-test-dist:
  149. SENTRY_BUILD=$(TRAVIS_COMMIT) SENTRY_LIGHT_BUILD=0 python setup.py sdist bdist_wheel
  150. @ls -lh dist/
  151. .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
  152. scan-python:
  153. @echo "--> Running Python vulnerability scanner"
  154. $(PIP) install safety
  155. bin/scan
  156. @echo ""
  157. travis-scan-sqlite: scan-python
  158. travis-scan-postgres: scan-python
  159. travis-scan-mysql: scan-python
  160. travis-scan-acceptance: travis-noop
  161. travis-scan-snuba: scan-python
  162. travis-scan-js: travis-noop
  163. travis-scan-cli: travis-noop
  164. travis-scan-dist: travis-noop