Makefile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. CPUS ?= $(shell sysctl -n hw.ncpu 2> /dev/null || echo 1)
  2. MAKEFLAGS += --jobs=$(CPUS)
  3. NPM_ROOT = ./node_modules
  4. STATIC_DIR = src/sentry/static/sentry
  5. ifneq "$(wildcard /usr/local/opt/libxmlsec1/lib)" ""
  6. LDFLAGS += -L/usr/local/opt/libxmlsec1/lib
  7. endif
  8. ifneq "$(wildcard /usr/local/opt/openssl/lib)" ""
  9. LDFLAGS += -L/usr/local/opt/openssl/lib
  10. endif
  11. PIP = LDFLAGS="$(LDFLAGS)" pip
  12. develop-only: update-submodules install-brew install-python install-yarn
  13. develop: setup-git develop-only
  14. @echo ""
  15. install-yarn:
  16. @echo "--> Installing Node dependencies"
  17. @hash yarn 2> /dev/null || (echo 'Cannot continue with JavaScript dependencies. Please install yarn before proceeding. For more information refer to https://yarnpkg.com/lang/en/docs/install/'; echo 'If you are on a mac run:'; echo ' brew install yarn'; exit 1)
  18. # Use NODE_ENV=development so that yarn installs both dependencies + devDependencies
  19. NODE_ENV=development yarn install --pure-lockfile
  20. # Fix phantomjs-prebuilt not installed via yarn
  21. # See: https://github.com/karma-runner/karma-phantomjs-launcher/issues/120#issuecomment-262634703
  22. node ./node_modules/phantomjs-prebuilt/install.js
  23. install-brew:
  24. @hash brew 2> /dev/null && brew bundle || (echo '! Homebrew not found, skipping system dependencies.')
  25. install-python:
  26. # must be executed serialially
  27. $(MAKE) install-python-base
  28. $(MAKE) install-python-develop
  29. install-python-base:
  30. @echo "--> Installing Python dependencies"
  31. $(PIP) install "setuptools>=0.9.8" "pip>=8.0.0"
  32. # order matters here, base package must install first
  33. $(PIP) install -e .
  34. $(PIP) install ujson
  35. $(PIP) install "file://`pwd`#egg=sentry[dev]"
  36. install-python-develop:
  37. $(PIP) install "file://`pwd`#egg=sentry[dev,tests]"
  38. install-python-tests:
  39. $(PIP) install "file://`pwd`#egg=sentry[dev,tests,optional]"
  40. dev-postgres: install-python
  41. dev-docs:
  42. $(PIP) install -r doc-requirements.txt
  43. reset-db:
  44. @echo "--> Dropping existing 'sentry' database"
  45. dropdb sentry || true
  46. @echo "--> Creating 'sentry' database"
  47. createdb -E utf-8 sentry
  48. @echo "--> Applying migrations"
  49. sentry upgrade
  50. setup-git:
  51. @echo "--> Installing git hooks"
  52. git config branch.autosetuprebase always
  53. cd .git/hooks && ln -sf ../../config/hooks/* ./
  54. @echo ""
  55. build: locale
  56. clean:
  57. @echo "--> Cleaning static cache"
  58. rm -rf dist/* static/dist/*
  59. @echo "--> Cleaning integration docs cache"
  60. rm -rf src/sentry/integration-docs
  61. @echo "--> Cleaning pyc files"
  62. find . -name "*.pyc" -delete
  63. @echo "--> Cleaning python build artifacts"
  64. rm -rf build/ dist/ src/sentry/assets.json
  65. @echo ""
  66. build-js-po:
  67. mkdir -p build
  68. SENTRY_EXTRACT_TRANSLATIONS=1 ./node_modules/.bin/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. update-submodules:
  83. @echo "--> Updating git submodules"
  84. git submodule init
  85. git submodule update
  86. @echo ""
  87. build-platform-assets:
  88. @echo "--> Building platform assets"
  89. sentry init
  90. @echo "from sentry.utils.integrationdocs import sync_docs; sync_docs()" | sentry exec
  91. test: develop lint test-js test-python test-cli
  92. testloop: develop
  93. pip install pytest-xdist
  94. py.test tests -f
  95. test-cli:
  96. @echo "--> Testing CLI"
  97. rm -rf test_cli
  98. mkdir test_cli
  99. cd test_cli && sentry init test_conf > /dev/null
  100. cd test_cli && sentry --config=test_conf upgrade --traceback --noinput > /dev/null
  101. cd test_cli && sentry --config=test_conf help 2>&1 | grep start > /dev/null
  102. rm -r test_cli
  103. @echo ""
  104. test-js:
  105. @echo "--> Building static assets"
  106. @${NPM_ROOT}/.bin/webpack
  107. @echo "--> Running JavaScript tests"
  108. @npm run test-ci
  109. @echo ""
  110. # builds and creates percy snapshots
  111. test-styleguide:
  112. @echo "--> Building and snapshotting styleguide"
  113. @npm run snapshot
  114. @echo ""
  115. test-python: build-platform-assets
  116. @echo "--> Running Python tests"
  117. py.test tests/integration tests/sentry --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" || exit 1
  118. @echo ""
  119. test-network:
  120. @echo "--> Building platform assets"
  121. sentry init
  122. @echo "from sentry.utils.integrationdocs import sync_docs; sync_docs()" | sentry exec
  123. @echo "--> Running network tests"
  124. py.test tests/network --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml"
  125. @echo ""
  126. test-acceptance: build-platform-assets
  127. @echo "--> Building static assets"
  128. @${NPM_ROOT}/.bin/webpack
  129. @echo "--> Running acceptance tests"
  130. py.test tests/acceptance --cov . --cov-report="xml:coverage.xml" --junit-xml="junit.xml" --html="pytest.html"
  131. @echo ""
  132. lint: lint-python lint-js
  133. lint-python:
  134. @echo "--> Linting python"
  135. bin/lint --python
  136. @echo ""
  137. lint-js:
  138. @echo "--> Linting javascript"
  139. bin/lint --js
  140. @echo ""
  141. coverage: develop
  142. $(MAKE) test-python
  143. coverage html
  144. publish:
  145. python setup.py sdist bdist_wheel upload
  146. extract-api-docs:
  147. rm -rf api-docs/cache/*
  148. cd api-docs; python generator.py
  149. .PHONY: develop dev-postgres dev-docs setup-git build clean locale update-transifex update-submodules test testloop test-cli test-js test-styleguide test-python test-acceptance lint lint-python lint-js coverage publish
  150. ############################
  151. # Halt, Travis stuff below #
  152. ############################
  153. # Bases for all builds
  154. travis-upgrade-pip:
  155. python -m pip install "pip>=9,<10"
  156. travis-setup-cassandra:
  157. echo "create keyspace sentry with replication = {'class' : 'SimpleStrategy', 'replication_factor': 1};" | cqlsh --cqlversion=3.1.7
  158. echo 'create table nodestore (key text primary key, value blob, flags int);' | cqlsh -k sentry --cqlversion=3.1.7
  159. travis-install-python:
  160. $(MAKE) travis-upgrade-pip
  161. $(MAKE) install-python-base
  162. $(MAKE) install-python-tests
  163. python -m pip install codecov
  164. travis-noop:
  165. @echo "nothing to do here."
  166. .PHONY: travis-upgrade-pip travis-setup-cassandra travis-install-python travis-noop
  167. travis-install-danger:
  168. bundle install
  169. travis-install-sqlite: travis-install-python
  170. travis-install-postgres: travis-install-python dev-postgres
  171. psql -c 'create database sentry;' -U postgres
  172. travis-install-mysql: travis-install-python
  173. pip install mysqlclient
  174. echo 'create database sentry;' | mysql -uroot
  175. travis-install-acceptance: install-yarn travis-install-postgres
  176. travis-install-network: travis-install-postgres
  177. travis-install-js:
  178. $(MAKE) travis-upgrade-pip
  179. $(MAKE) travis-install-python install-yarn
  180. travis-install-cli: travis-install-postgres
  181. travis-install-dist:
  182. $(MAKE) travis-upgrade-pip
  183. $(MAKE) travis-install-python install-yarn
  184. travis-install-django-18: travis-install-postgres
  185. pip install "Django>=1.8,<1.9"
  186. .PHONY: travis-install-danger travis-install-sqlite travis-install-postgres travis-install-js travis-install-cli travis-install-dist
  187. # Lint steps
  188. travis-lint-danger: travis-noop
  189. travis-lint-sqlite: lint-python
  190. travis-lint-postgres: lint-python
  191. travis-lint-mysql: lint-python
  192. travis-lint-acceptance: travis-noop
  193. travis-lint-network: lint-python
  194. travis-lint-js: lint-js
  195. travis-lint-cli: travis-noop
  196. travis-lint-dist: travis-noop
  197. travis-lint-django-18: travis-lint-postgres
  198. .PHONY: travis-lint-danger travis-lint-sqlite travis-lint-postgres travis-lint-mysql travis-lint-js travis-lint-cli travis-lint-dist
  199. # Test steps
  200. travis-test-danger:
  201. bundle exec danger
  202. travis-test-sqlite: test-python
  203. travis-test-postgres: test-python
  204. travis-test-mysql: test-python
  205. travis-test-acceptance: test-acceptance
  206. travis-test-network: test-network
  207. travis-test-js:
  208. $(MAKE) test-js
  209. $(MAKE) test-styleguide
  210. travis-test-cli: test-cli
  211. travis-test-dist:
  212. SENTRY_BUILD=$(TRAVIS_COMMIT) SENTRY_LIGHT_BUILD=0 python setup.py sdist bdist_wheel
  213. @ls -lh dist/
  214. travis-test-django-18: travis-test-postgres
  215. .PHONY: travis-test-danger travis-test-sqlite travis-test-postgres travis-test-mysql travis-test-js travis-test-cli travis-test-dist