.travis.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. dist: xenial
  2. language: python
  3. python: 2.7
  4. branches:
  5. only:
  6. - master
  7. cache:
  8. yarn: true
  9. directories:
  10. - "${HOME}/virtualenv/python$(python -c 'import platform; print(platform.python_version())')"
  11. - '$VOLTA_HOME'
  12. - node_modules
  13. - '${HOME}/google-cloud-sdk'
  14. addons:
  15. apt:
  16. update: true
  17. packages:
  18. - libxmlsec1-dev
  19. - libmaxminddb-dev
  20. chrome: stable
  21. env:
  22. global:
  23. - NODE_ENV=development
  24. - PIP_DISABLE_PIP_VERSION_CHECK=on
  25. - PIP_QUIET=1
  26. - SENTRY_LIGHT_BUILD=1
  27. - SENTRY_SKIP_BACKEND_VALIDATION=1
  28. - MIGRATIONS_TEST_MIGRATE=0
  29. # Use this to override the django version in the requirements file.
  30. - DJANGO_VERSION=">=1.11,<1.12"
  31. - VOLTA_VERSION=0.8.1
  32. - VOLTA_HOME="${HOME}/.volta"
  33. - PATH="${HOME}/.volta/bin:${PATH}"
  34. - NODE_OPTIONS=--max-old-space-size=4096
  35. - PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079
  36. - SENTRY_KAFKA_HOSTS=localhost:9092
  37. - SENTRY_ZOOKEEPER_HOSTS=localhost:2181
  38. - PYTEST_ADDOPTS="--reruns 5"
  39. base_install: &base_install |-
  40. pip install --no-cache-dir "pip>=20.0.2"
  41. docker run \
  42. --name sentry_zookeeper \
  43. -d --network host \
  44. -e ZOOKEEPER_CLIENT_PORT=2181 \
  45. confluentinc/cp-zookeeper:4.1.0
  46. docker run \
  47. --name sentry_kafka \
  48. -d --network host \
  49. -e KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
  50. -e KAFKA_LISTENERS=INTERNAL://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092 \
  51. -e KAFKA_ADVERTISED_LISTENERS=INTERNAL://127.0.0.1:9093,EXTERNAL://127.0.0.1:9092 \
  52. -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT \
  53. -e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL \
  54. -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  55. confluentinc/cp-kafka:5.1.2
  56. [ "$TRAVIS_PULL_REQUEST" != "false" ] || export PYTEST_SENTRY_ALWAYS_REPORT=1
  57. install_volta: &install_volta |-
  58. command -v volta && return 0
  59. wget --quiet "https://github.com/volta-cli/volta/releases/download/v$VOLTA_VERSION/volta-$VOLTA_VERSION-linux-openssl-1.0.tar.gz"
  60. tar -xzf "volta-$VOLTA_VERSION-linux-openssl-1.0.tar.gz" -C "${HOME}/bin"
  61. # Running `volta -v` triggers setting up the shims in VOLTA_HOME (otherwise node won't work)
  62. volta -v
  63. install_node_dependencies: &install_node_dependencies |-
  64. # Running `node -v` and `yarn -v` triggers Volta to install the versions set in the project.
  65. # There might be a more readable `volta install` in the future that would replace this magic.
  66. # Tracking: https://github.com/volta-cli/volta/issues/653#issuecomment-628909923
  67. node -v
  68. yarn -v
  69. yarn install --frozen-lockfile
  70. start_snuba: &start_snuba |-
  71. docker run \
  72. --name sentry_clickhouse \
  73. -d --network host \
  74. --ulimit nofile=262144:262144 \
  75. yandex/clickhouse-server:19.11 \
  76. docker run \
  77. --name sentry_snuba \
  78. -d --network host \
  79. -e SNUBA_SETTINGS=test \
  80. -e CLICKHOUSE_HOST=127.0.0.1 \
  81. -e CLICKHOUSE_PORT=9000 \
  82. getsentry/snuba
  83. script:
  84. # certain commands require sentry init to be run, but this is only true for
  85. # running things within Travis
  86. - make travis-test-$TEST_SUITE
  87. # installing dependencies for after_* steps here ensures they get cached
  88. # since those steps execute after travis runs `store build cache`
  89. after_failure:
  90. - dmesg | tail -n 100
  91. after_script:
  92. - |
  93. coverage_files=$(ls .artifacts/*coverage.xml || true)
  94. if [[ -n "$coverage_files" || -f .artifacts/coverage/cobertura-coverage.xml ]]; then
  95. pip install -U codecov
  96. codecov -e TEST_SUITE
  97. fi
  98. - *install_volta
  99. - volta install @zeus-ci/cli
  100. - zeus upload -t "text/xml+xunit" .artifacts/*junit.xml
  101. - zeus upload -t "text/xml+coverage" .artifacts/*coverage.xml
  102. - zeus upload -t "text/xml+coverage" .artifacts/coverage/cobertura-coverage.xml
  103. - zeus upload -t "text/html+pytest" .artifacts/*pytest.html
  104. - zeus upload -t "text/plain+pycodestyle" .artifacts/*pycodestyle.log
  105. - zeus upload -t "text/xml+checkstyle" .artifacts/*checkstyle.xml
  106. - zeus upload -t "application/webpack-stats+json" .artifacts/*webpack-stats.json
  107. base_postgres: &postgres_default
  108. python: 2.7
  109. services:
  110. - memcached
  111. - redis-server
  112. - postgresql
  113. before_install:
  114. - *base_install
  115. - *start_snuba
  116. - docker ps -a
  117. install:
  118. - python setup.py install_egg_info
  119. - pip install -U -e ".[dev]"
  120. before_script:
  121. - psql -c 'create database sentry;' -U postgres
  122. base_acceptance: &acceptance_default
  123. python: 2.7
  124. services:
  125. - docker
  126. - memcached
  127. - redis-server
  128. - postgresql
  129. before_install:
  130. - *base_install
  131. - *install_volta
  132. - *start_snuba
  133. - docker ps -a
  134. install:
  135. - *install_node_dependencies
  136. - python setup.py install_egg_info
  137. - pip install -U -e ".[dev]"
  138. - |
  139. CHROME_MAJOR_VERSION="$(dpkg -s google-chrome-stable | sed -nr 's/Version: ([0-9]+).*/\1/p')"
  140. wget -N "https://chromedriver.storage.googleapis.com/$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION})/chromedriver_linux64.zip" -P ~/
  141. - unzip ~/chromedriver_linux64.zip -d ~/
  142. - rm ~/chromedriver_linux64.zip
  143. - install -m755 ~/chromedriver -C "${HOME}/bin"
  144. before_script:
  145. - psql -c 'create database sentry;' -U postgres
  146. # each job in the matrix inherits `env/global` and uses everything above,
  147. # but custom `services`, `before_install`, `install`, and `before_script` directives
  148. # may be defined to define and setup individual job environments with more precision.
  149. matrix:
  150. fast_finish: true
  151. include:
  152. - language: generic
  153. name: 'Linter (Javascript)'
  154. env: TEST_SUITE=lint-js
  155. before_install:
  156. # Under a "generic" language environment, this will make travis pyenv error because there
  157. # is no pyenv python installed.
  158. - rm .python-version
  159. - *install_volta
  160. install:
  161. - *install_node_dependencies
  162. - python: 3.7
  163. name: 'pre-commit hooks (includes python linting + format check)'
  164. install:
  165. # XXX: this must be synced with requirements-dev.txt
  166. - pip install 'sentry-flake8==0.3.0'
  167. - SENTRY_NO_VIRTUALENV_CREATION=1 make setup-git
  168. script:
  169. # Run pre-commit to lint and format check files that were changed (but not deleted) compared to master.
  170. # XXX: there is a very small chance that it'll expand to exceed Linux's limits
  171. # `getconf ARG_MAX` - max # bytes of args + environ for exec()
  172. - pre-commit run --files $(git diff --diff-filter=d --name-only master)
  173. - <<: *postgres_default
  174. name: 'Backend with migrations [Postgres] (1/2)'
  175. env: TEST_SUITE=postgres DB=postgres TOTAL_TEST_GROUPS=2 TEST_GROUP=0 MIGRATIONS_TEST_MIGRATE=1
  176. - <<: *postgres_default
  177. name: 'Backend with migrations [Postgres] (2/2)'
  178. env: TEST_SUITE=postgres DB=postgres TOTAL_TEST_GROUPS=2 TEST_GROUP=1 MIGRATIONS_TEST_MIGRATE=1
  179. - <<: *acceptance_default
  180. name: 'Acceptance (1/3)'
  181. env: TEST_SUITE=acceptance USE_SNUBA=1 TOTAL_TEST_GROUPS=3 TEST_GROUP=0
  182. - <<: *acceptance_default
  183. name: 'Acceptance (2/3)'
  184. env: TEST_SUITE=acceptance USE_SNUBA=1 TOTAL_TEST_GROUPS=3 TEST_GROUP=1
  185. - <<: *acceptance_default
  186. name: 'Acceptance (3/3)'
  187. env: TEST_SUITE=acceptance USE_SNUBA=1 TOTAL_TEST_GROUPS=3 TEST_GROUP=2
  188. - <<: *acceptance_default
  189. name: 'Plugins'
  190. env: TEST_SUITE=plugins DB=postgres
  191. - python: 2.7
  192. name: 'Frontend [test]'
  193. env: TEST_SUITE=js
  194. before_install:
  195. - *install_volta
  196. install:
  197. - *install_node_dependencies
  198. - python: 2.7
  199. name: 'Frontend [build]'
  200. env: TEST_SUITE=js-build
  201. before_install:
  202. - *install_volta
  203. install:
  204. - *install_node_dependencies
  205. - python: 2.7
  206. name: 'Command Line'
  207. env: TEST_SUITE=cli
  208. services:
  209. - postgresql
  210. - redis-server
  211. install:
  212. - python setup.py install_egg_info
  213. - pip install -U -e ".[dev]"
  214. before_script:
  215. - psql -c 'create database sentry;' -U postgres
  216. - <<: *postgres_default
  217. name: 'Symbolicator Integration'
  218. env: TEST_SUITE=symbolicator
  219. before_install:
  220. - *base_install
  221. - *start_snuba
  222. - docker run -d --network host --name symbolicator us.gcr.io/sentryio/symbolicator:latest run
  223. - docker ps -a
  224. - <<: *postgres_default
  225. name: 'Sentry-Relay integration tests'
  226. env: TEST_SUITE=relay-integration DB=postgres
  227. services:
  228. - docker
  229. - memcached
  230. - redis-server
  231. - postgresql
  232. before_install:
  233. - *base_install
  234. - *start_snuba
  235. - docker pull us.gcr.io/sentryio/relay:latest # pull relay we'll run and kill it for each test
  236. - docker ps -a
  237. - python: 2.7
  238. name: 'Snuba Integration with migrations'
  239. env: TEST_SUITE=snuba USE_SNUBA=1 MIGRATIONS_TEST_MIGRATE=1
  240. services:
  241. - docker
  242. - memcached
  243. - redis-server
  244. - postgresql
  245. before_install:
  246. - *base_install
  247. - *start_snuba
  248. - docker ps -a
  249. install:
  250. - python setup.py install_egg_info
  251. - pip install -U -e ".[dev]"
  252. before_script:
  253. - psql -c 'create database sentry;' -U postgres
  254. # XXX: this needs to be the same as postgres_default (other than python, name, env, and the rb package override)
  255. # NOTE: Migrations need to also be ported to py3.6, but the errors just clog up everything.
  256. # So for now, we're unblocking that by not having MIGRATIONS_TEST_MIGRATE=1.
  257. # Allowed to fail!
  258. # - python: 3.6
  259. # name: 'Python 3.6 backend (no migrations) [Postgres]'
  260. # env: TEST_SUITE=postgres DB=postgres SENTRY_PYTHON3=1 PYTEST_ADDOPTS="" PYTEST_SENTRY_ALWAYS_REPORT=no
  261. # services:
  262. # - memcached
  263. # - redis-server
  264. # - postgresql
  265. # before_install:
  266. # - *base_install
  267. # - *start_snuba
  268. # - docker ps -a
  269. # install:
  270. # - python setup.py install_egg_info
  271. # - pip install -U -e ".[dev]"
  272. # - pip uninstall -y rb
  273. # - pip install -e git+https://github.com/joshuarli/rb.git@505ad7665baba66c7c492b01b0e83d433ed2eb8e#egg=rb
  274. # before_script:
  275. # - psql -c 'create database sentry;' -U postgres
  276. # Deploy 'storybook' (component & style guide)
  277. - name: 'Storybook Deploy'
  278. language: generic
  279. env: STORYBOOK_BUILD=1
  280. before_install:
  281. # travis pyenv will attempt to use .python-version, but the appropriate python version won't be installed.
  282. # since we don't need python here, we have to remove this.
  283. - rm .python-version
  284. - *install_volta
  285. install:
  286. - *install_node_dependencies
  287. script: yarn run storybook-build
  288. after_success: .travis/deploy-storybook.sh
  289. after_failure: skip
  290. notifications:
  291. webhooks:
  292. urls:
  293. - https://zeus.ci/hooks/fa079cf6-8e6b-11e7-9155-0a580a28081c/public/provider/travis/webhook
  294. # This is to capture travis metrics
  295. # Repo for this webhook is https://github.com/getsentry/sentry-development-metrics
  296. # Hosted on GCP
  297. - https://product-eng-webhooks-vmrqv3f7nq-uw.a.run.app/metrics/travis/webhook
  298. on_success: always
  299. on_failure: always
  300. on_start: always
  301. on_cancel: always
  302. on_error: always