Makefile 8.0 KB

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