.travis.yml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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:20.3.9.70 \
  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. docker exec sentry_snuba snuba migrations migrate --force
  84. script:
  85. - make travis-test-$TEST_SUITE
  86. after_failure:
  87. - dmesg | tail -n 100
  88. after_script:
  89. - |
  90. coverage_files=$(ls .artifacts/*coverage.xml || true)
  91. if [[ -n "$coverage_files" || -f .artifacts/coverage/cobertura-coverage.xml ]]; then
  92. pip install -U codecov
  93. codecov -e TEST_SUITE
  94. fi
  95. - *install_volta
  96. - volta install @zeus-ci/cli
  97. - zeus upload -t "text/xml+xunit" .artifacts/*junit.xml
  98. - zeus upload -t "text/xml+coverage" .artifacts/*coverage.xml
  99. - zeus upload -t "text/xml+coverage" .artifacts/coverage/cobertura-coverage.xml
  100. - zeus upload -t "text/html+pytest" .artifacts/*pytest.html
  101. - zeus upload -t "text/plain+pycodestyle" .artifacts/*pycodestyle.log
  102. - zeus upload -t "text/xml+checkstyle" .artifacts/*checkstyle.xml
  103. - zeus upload -t "application/webpack-stats+json" .artifacts/*webpack-stats.json
  104. base_postgres: &postgres_default
  105. python: 2.7
  106. services:
  107. - memcached
  108. - redis-server
  109. - postgresql
  110. before_install:
  111. - *base_install
  112. - *start_snuba
  113. - docker ps -a
  114. install:
  115. - python setup.py install_egg_info
  116. - pip install -U -e ".[dev]"
  117. - sentry init
  118. before_script:
  119. - psql -c 'create database sentry;' -U postgres
  120. base_acceptance: &acceptance_default
  121. python: 2.7
  122. services:
  123. - docker
  124. - memcached
  125. - redis-server
  126. - postgresql
  127. before_install:
  128. - *base_install
  129. - *install_volta
  130. - *start_snuba
  131. - docker ps -a
  132. install:
  133. - *install_node_dependencies
  134. - python setup.py install_egg_info
  135. - pip install -U -e ".[dev]"
  136. - sentry init
  137. - |
  138. CHROME_MAJOR_VERSION="$(dpkg -s google-chrome-stable | sed -nr 's/Version: ([0-9]+).*/\1/p')"
  139. wget -N "https://chromedriver.storage.googleapis.com/$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION})/chromedriver_linux64.zip" -P ~/
  140. - unzip ~/chromedriver_linux64.zip -d ~/
  141. - rm ~/chromedriver_linux64.zip
  142. - install -m755 ~/chromedriver -C "${HOME}/bin"
  143. before_script:
  144. - psql -c 'create database sentry;' -U postgres
  145. # each job in the matrix inherits `env/global` and uses everything above,
  146. # but custom `services`, `before_install`, `install`, and `before_script` directives
  147. # may be defined to define and setup individual job environments with more precision.
  148. matrix:
  149. fast_finish: true
  150. include:
  151. - language: generic
  152. name: 'Linter (Javascript)'
  153. env: TEST_SUITE=lint-js
  154. before_install:
  155. # Under a "generic" language environment, this will make travis pyenv error because there
  156. # is no pyenv python installed.
  157. - rm .python-version
  158. - *install_volta
  159. install:
  160. - *install_node_dependencies
  161. - python: 3.7
  162. name: 'pre-commit hooks (includes python linting + format check)'
  163. install:
  164. - SENTRY_NO_VIRTUALENV_CREATION=1 make setup-git
  165. script:
  166. # Run pre-commit to lint and format check files that were changed (but not deleted) compared to master.
  167. # XXX: there is a very small chance that it'll expand to exceed Linux's limits
  168. # `getconf ARG_MAX` - max # bytes of args + environ for exec()
  169. - pre-commit run --files $(git diff --diff-filter=d --name-only master)
  170. - <<: *postgres_default
  171. name: 'Backend with migrations [Postgres] (1/2)'
  172. env: TEST_SUITE=postgres DB=postgres TOTAL_TEST_GROUPS=2 TEST_GROUP=0 MIGRATIONS_TEST_MIGRATE=1
  173. - <<: *postgres_default
  174. name: 'Backend with migrations [Postgres] (2/2)'
  175. env: TEST_SUITE=postgres DB=postgres TOTAL_TEST_GROUPS=2 TEST_GROUP=1 MIGRATIONS_TEST_MIGRATE=1
  176. - <<: *acceptance_default
  177. name: 'Acceptance (1/3)'
  178. env: TEST_SUITE=acceptance USE_SNUBA=1 TOTAL_TEST_GROUPS=3 TEST_GROUP=0
  179. - <<: *acceptance_default
  180. name: 'Acceptance (2/3)'
  181. env: TEST_SUITE=acceptance USE_SNUBA=1 TOTAL_TEST_GROUPS=3 TEST_GROUP=1
  182. - <<: *acceptance_default
  183. name: 'Acceptance (3/3)'
  184. env: TEST_SUITE=acceptance USE_SNUBA=1 TOTAL_TEST_GROUPS=3 TEST_GROUP=2
  185. - <<: *acceptance_default
  186. name: 'Plugins'
  187. env: TEST_SUITE=plugins DB=postgres
  188. - python: 2.7
  189. name: 'Frontend [test]'
  190. env: TEST_SUITE=js
  191. before_install:
  192. - *install_volta
  193. install:
  194. - *install_node_dependencies
  195. - python: 2.7
  196. name: 'Frontend [build]'
  197. env: TEST_SUITE=js-build
  198. before_install:
  199. - *install_volta
  200. install:
  201. - *install_node_dependencies
  202. - python: 2.7
  203. name: 'Command Line'
  204. env: TEST_SUITE=cli
  205. services:
  206. - postgresql
  207. - redis-server
  208. install:
  209. - python setup.py install_egg_info
  210. - pip install -U -e ".[dev]"
  211. - sentry init
  212. before_script:
  213. - psql -c 'create database sentry;' -U postgres
  214. - <<: *postgres_default
  215. name: 'Symbolicator Integration'
  216. env: TEST_SUITE=symbolicator
  217. before_install:
  218. - *base_install
  219. - *start_snuba
  220. - docker run -d --network host --name symbolicator us.gcr.io/sentryio/symbolicator:latest run
  221. - docker ps -a
  222. - <<: *postgres_default
  223. name: 'Sentry-Relay integration tests'
  224. env: TEST_SUITE=relay-integration DB=postgres
  225. services:
  226. - docker
  227. - memcached
  228. - redis-server
  229. - postgresql
  230. before_install:
  231. - *base_install
  232. - *start_snuba
  233. - docker pull us.gcr.io/sentryio/relay:latest # pull relay we'll run and kill it for each test
  234. - docker ps -a
  235. - python: 2.7
  236. name: 'Snuba Integration with migrations'
  237. env: TEST_SUITE=snuba USE_SNUBA=1 MIGRATIONS_TEST_MIGRATE=1
  238. services:
  239. - docker
  240. - memcached
  241. - redis-server
  242. - postgresql
  243. before_install:
  244. - *base_install
  245. - *start_snuba
  246. - docker ps -a
  247. install:
  248. - python setup.py install_egg_info
  249. - pip install -U -e ".[dev]"
  250. - sentry init
  251. before_script:
  252. - psql -c 'create database sentry;' -U postgres
  253. # Deploy 'storybook' (component & style guide)
  254. - name: 'Storybook Deploy'
  255. language: generic
  256. env: STORYBOOK_BUILD=1
  257. before_install:
  258. # travis pyenv will attempt to use .python-version, but the appropriate python version won't be installed.
  259. # since we don't need python here, we have to remove this.
  260. - rm .python-version
  261. - *install_volta
  262. install:
  263. - *install_node_dependencies
  264. script: yarn run storybook-build
  265. after_success: .travis/deploy-storybook.sh
  266. after_failure: skip
  267. notifications:
  268. webhooks:
  269. urls:
  270. - https://zeus.ci/hooks/fa079cf6-8e6b-11e7-9155-0a580a28081c/public/provider/travis/webhook
  271. # This is to capture travis metrics
  272. # Repo for this webhook is https://github.com/getsentry/sentry-development-metrics
  273. # Hosted on GCP
  274. - https://product-eng-webhooks-vmrqv3f7nq-uw.a.run.app/metrics/travis/webhook
  275. on_success: always
  276. on_failure: always
  277. on_start: always
  278. on_cancel: always
  279. on_error: always