.travis.yml 9.8 KB

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