Makefile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. CPUS ?= $(shell sysctl -n hw.ncpu || echo 1)
  2. MAKEFLAGS += --jobs=$(CPUS)
  3. NPM_ROOT = ./node_modules
  4. STATIC_DIR = src/sentry/static/sentry
  5. develop: setup-git update-submodules install-python install-yarn
  6. @echo ""
  7. develop-only: develop
  8. install-yarn:
  9. @echo "--> Installing Node dependencies"
  10. @hash yarn 2> /dev/null || npm install -g yarn
  11. # Use NODE_ENV=development so that yarn installs both dependencies + devDependencies
  12. NODE_ENV=development yarn install --ignore-optional --pure-lockfile
  13. # Fix phantomjs-prebuilt not installed via yarn
  14. # See: https://github.com/karma-runner/karma-phantomjs-launcher/issues/120#issuecomment-262634703
  15. node ./node_modules/phantomjs-prebuilt/install.js
  16. install-python:
  17. # must be executed serialially
  18. $(MAKE) install-python-base
  19. $(MAKE) install-python-tests
  20. install-python-base:
  21. @echo "--> Installing Python dependencies"
  22. pip install "setuptools>=0.9.8"
  23. # order matters here, base package must install first
  24. pip install -e .
  25. pip install ujson
  26. pip install "file://`pwd`#egg=sentry[dev]"
  27. install-python-tests:
  28. pip install "file://`pwd`#egg=sentry[dev,tests,dsym]"
  29. dev-postgres: install-python
  30. dev-docs:
  31. pip install -r doc-requirements.txt
  32. reset-db:
  33. @echo "--> Dropping existing 'sentry' database"
  34. dropdb sentry || true
  35. @echo "--> Creating 'sentry' database"
  36. createdb -E utf-8 sentry
  37. @echo "--> Applying migrations"
  38. sentry upgrade
  39. setup-git:
  40. @echo "--> Installing git hooks"
  41. git config branch.autosetuprebase always
  42. cd .git/hooks && ln -sf ../../config/hooks/* ./
  43. @echo ""
  44. build: locale
  45. clean:
  46. @echo "--> Cleaning static cache"
  47. rm -rf dist/* static/dist/*
  48. @echo "--> Cleaning integration docs cache"
  49. rm -rf src/sentry/integration-docs
  50. @echo "--> Cleaning pyc files"
  51. find . -name "*.pyc" -delete
  52. @echo "--> Cleaning python build artifacts"
  53. rm -rf build/ dist/ src/sentry/assets.json
  54. @echo ""
  55. build-js-po:
  56. mkdir -p build
  57. SENTRY_EXTRACT_TRANSLATIONS=1 ./node_modules/.bin/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 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. update-submodules:
  72. @echo "--> Updating git submodules"
  73. git submodule init
  74. git submodule update
  75. @echo ""
  76. test: develop lint test-js test-python test-cli
  77. testloop: develop
  78. pip install pytest-xdist
  79. py.test tests -f
  80. test-cli:
  81. @echo "--> Testing CLI"
  82. rm -rf test_cli
  83. mkdir test_cli
  84. cd test_cli && sentry init test_conf > /dev/null
  85. cd test_cli && sentry --config=test_conf upgrade --traceback --noinput > /dev/null
  86. cd test_cli && sentry --config=test_conf help 2>&1 | grep start > /dev/null
  87. rm -r test_cli
  88. @echo ""
  89. test-js:
  90. @echo "--> Building static assets"
  91. @${NPM_ROOT}/.bin/webpack
  92. @echo "--> Running JavaScript tests"
  93. @npm run test
  94. @echo ""
  95. test-python:
  96. @echo "--> Running Python tests"
  97. py.test tests/integration tests/sentry || exit 1
  98. @echo ""
  99. test-acceptance:
  100. @echo "--> Building static assets"
  101. @${NPM_ROOT}/.bin/webpack
  102. @echo "--> Running acceptance tests"
  103. py.test tests/acceptance
  104. @echo ""
  105. test-python-coverage:
  106. @echo "--> Running Python tests"
  107. SOUTH_TESTS_MIGRATE=1 coverage run --source=src/sentry -m py.test tests/integration tests/sentry
  108. @echo ""
  109. lint: lint-python lint-js
  110. lint-python:
  111. @echo "--> Linting python"
  112. bin/lint --python
  113. @echo ""
  114. lint-js:
  115. @echo "--> Linting javascript"
  116. bin/lint --js
  117. @echo ""
  118. coverage: develop
  119. $(MAKE) test-python-coverage
  120. coverage html
  121. publish:
  122. python setup.py sdist bdist_wheel upload
  123. extract-api-docs:
  124. rm -rf api-docs/cache/*
  125. cd api-docs; python generator.py
  126. .PHONY: develop dev-postgres dev-docs setup-git build clean locale update-transifex update-submodules test testloop test-cli test-js test-python test-acceptance test-python-coverage lint lint-python lint-js coverage publish
  127. ############################
  128. # Halt, Travis stuff below #
  129. ############################
  130. # Bases for all builds
  131. travis-upgrade-pip:
  132. python -m pip install pip==8.1.1
  133. travis-setup-cassandra:
  134. echo "create keyspace sentry with replication = {'class' : 'SimpleStrategy', 'replication_factor': 1};" | cqlsh --cqlversion=3.1.7
  135. echo 'create table nodestore (key text primary key, value blob, flags int);' | cqlsh -k sentry --cqlversion=3.1.7
  136. travis-install-python:
  137. $(MAKE) travis-upgrade-pip
  138. $(MAKE) install-python install-python
  139. python -m pip install codecov
  140. travis-noop:
  141. @echo "nothing to do here."
  142. .PHONY: travis-upgrade-pip travis-setup-cassandra travis-install-python travis-noop
  143. travis-install-danger:
  144. bundle install
  145. travis-install-sqlite: travis-install-python
  146. travis-install-postgres: travis-install-python dev-postgres
  147. psql -c 'create database sentry;' -U postgres
  148. travis-install-mysql: travis-install-python
  149. pip install mysqlclient
  150. echo 'create database sentry;' | mysql -uroot
  151. travis-install-acceptance: install-yarn travis-install-postgres
  152. travis-install-js:
  153. $(MAKE) travis-upgrade-pip
  154. $(MAKE) install-python install-yarn
  155. travis-install-cli: travis-install-postgres
  156. travis-install-dist:
  157. $(MAKE) travis-upgrade-pip
  158. $(MAKE) install-python install-yarn
  159. travis-install-django-18: travis-install-postgres
  160. pip install "Django>=1.8,<1.9"
  161. .PHONY: travis-install-danger travis-install-sqlite travis-install-postgres travis-install-js travis-install-cli travis-install-dist
  162. # Lint steps
  163. travis-lint-danger: travis-noop
  164. travis-lint-sqlite: lint-python
  165. travis-lint-postgres: lint-python
  166. travis-lint-mysql: lint-python
  167. travis-lint-acceptance: travis-noop
  168. travis-lint-js: lint-js
  169. travis-lint-cli: travis-noop
  170. travis-lint-dist: travis-noop
  171. travis-lint-django-18: travis-lint-postgres
  172. .PHONY: travis-lint-danger travis-lint-sqlite travis-lint-postgres travis-lint-mysql travis-lint-js travis-lint-cli travis-lint-dist
  173. # Test steps
  174. travis-test-danger:
  175. bundle exec danger
  176. travis-test-sqlite: test-python-coverage
  177. travis-test-postgres: test-python-coverage
  178. travis-test-mysql: test-python-coverage
  179. travis-test-acceptance: test-acceptance
  180. travis-test-js: test-js
  181. travis-test-cli: test-cli
  182. travis-test-dist:
  183. SENTRY_BUILD=$(TRAVIS_COMMIT) SENTRY_LIGHT_BUILD=0 python setup.py sdist bdist_wheel
  184. @ls -lh dist/
  185. travis-test-django-18: travis-test-postgres
  186. .PHONY: travis-test-danger travis-test-sqlite travis-test-postgres travis-test-mysql travis-test-js travis-test-cli travis-test-dist