.travis.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. - '$NODE_DIR'
  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. # node's version is pinned by .nvmrc and is autodetected by `nvm install`.
  32. - NODE_DIR="${HOME}/.nvm/versions/node/v$(< .nvmrc)"
  33. - NODE_OPTIONS=--max-old-space-size=4096
  34. - PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079
  35. - SENTRY_KAFKA_HOSTS=localhost:9092
  36. - SENTRY_ZOOKEEPER_HOSTS=localhost:2181
  37. - PYTEST_ADDOPTS="--reruns 5"
  38. base_install: &base_install |-
  39. pip install --no-cache-dir "pip>=20.0.2"
  40. docker run \
  41. --name sentry_zookeeper \
  42. -d --network host \
  43. -e ZOOKEEPER_CLIENT_PORT=2181 \
  44. confluentinc/cp-zookeeper:4.1.0
  45. docker run \
  46. --name sentry_kafka \
  47. -d --network host \
  48. -e KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
  49. -e KAFKA_LISTENERS=INTERNAL://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092 \
  50. -e KAFKA_ADVERTISED_LISTENERS=INTERNAL://127.0.0.1:9093,EXTERNAL://127.0.0.1:9092 \
  51. -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT \
  52. -e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL \
  53. -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  54. confluentinc/cp-kafka:5.1.2
  55. [ "$TRAVIS_PULL_REQUEST" != "false" ] || export PYTEST_SENTRY_ALWAYS_REPORT=1
  56. start_snuba: &start_snuba |-
  57. docker run \
  58. --name sentry_clickhouse \
  59. -d --network host \
  60. --ulimit nofile=262144:262144 \
  61. yandex/clickhouse-server:19.11 \
  62. docker run \
  63. --name sentry_snuba \
  64. -d --network host \
  65. -e SNUBA_SETTINGS=test \
  66. -e CLICKHOUSE_HOST=127.0.0.1 \
  67. -e CLICKHOUSE_PORT=9000 \
  68. getsentry/snuba
  69. script:
  70. # certain commands require sentry init to be run, but this is only true for
  71. # running things within Travis
  72. - make travis-test-$TEST_SUITE
  73. # installing dependencies for after_* steps here ensures they get cached
  74. # since those steps execute after travis runs `store build cache`
  75. after_failure:
  76. - dmesg | tail -n 100
  77. after_script:
  78. - |
  79. coverage_files=$(ls .artifacts/*coverage.xml || true)
  80. if [[ -n "$coverage_files" || -f .artifacts/coverage/cobertura-coverage.xml ]]; then
  81. pip install -U codecov
  82. codecov -e TEST_SUITE
  83. fi
  84. - ./bin/yarn global add @zeus-ci/cli
  85. - $(./bin/yarn global bin)/zeus upload -t "text/xml+xunit" .artifacts/*junit.xml
  86. - $(./bin/yarn global bin)/zeus upload -t "text/xml+coverage" .artifacts/*coverage.xml
  87. - $(./bin/yarn global bin)/zeus upload -t "text/xml+coverage" .artifacts/coverage/cobertura-coverage.xml
  88. - $(./bin/yarn global bin)/zeus upload -t "text/html+pytest" .artifacts/*pytest.html
  89. - $(./bin/yarn global bin)/zeus upload -t "text/plain+pycodestyle" .artifacts/*pycodestyle.log
  90. - $(./bin/yarn global bin)/zeus upload -t "text/xml+checkstyle" .artifacts/*checkstyle.xml
  91. - $(./bin/yarn global bin)/zeus upload -t "application/webpack-stats+json" .artifacts/*webpack-stats.json
  92. base_postgres: &postgres_default
  93. python: 2.7
  94. services:
  95. - memcached
  96. - redis-server
  97. - postgresql
  98. before_install:
  99. - *base_install
  100. - *start_snuba
  101. - docker ps -a
  102. install:
  103. - python setup.py install_egg_info
  104. - pip install -U -e ".[dev]"
  105. before_script:
  106. - psql -c 'create database sentry;' -U postgres
  107. base_acceptance: &acceptance_default
  108. python: 2.7
  109. services:
  110. - docker
  111. - memcached
  112. - redis-server
  113. - postgresql
  114. before_install:
  115. - *base_install
  116. - *start_snuba
  117. - find "$NODE_DIR" -type d -empty -delete
  118. - nvm install
  119. - docker ps -a
  120. install:
  121. - ./bin/yarn install --frozen-lockfile
  122. - python setup.py install_egg_info
  123. - pip install -U -e ".[dev]"
  124. - |
  125. CHROME_MAJOR_VERSION="$(dpkg -s google-chrome-stable | sed -nr 's/Version: ([0-9]+).*/\1/p')"
  126. wget -N "https://chromedriver.storage.googleapis.com/$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION})/chromedriver_linux64.zip" -P ~/
  127. - unzip ~/chromedriver_linux64.zip -d ~/
  128. - rm ~/chromedriver_linux64.zip
  129. - sudo install -m755 ~/chromedriver /usr/local/bin/
  130. before_script:
  131. - psql -c 'create database sentry;' -U postgres
  132. # each job in the matrix inherits `env/global` and uses everything above,
  133. # but custom `services`, `before_install`, `install`, and `before_script` directives
  134. # may be defined to define and setup individual job environments with more precision.
  135. matrix:
  136. fast_finish: true
  137. include:
  138. - language: generic
  139. name: 'Linter (Javascript)'
  140. env: TEST_SUITE=lint-js
  141. install:
  142. - find "$NODE_DIR" -type d -empty -delete
  143. # Under a "generic" language environment, this will make travis pyenv error because there
  144. # is no pyenv python installed.
  145. - rm .python-version
  146. - nvm install
  147. - ./bin/yarn install --frozen-lockfile
  148. - python: 3.7
  149. name: 'pre-commit hooks (includes python linting + format check) and dependency scanning'
  150. install:
  151. # XXX: this must be synced with requirements-dev.txt
  152. - pip install 'sentry-flake8==0.3.0'
  153. - SENTRY_NO_VIRTUALENV_CREATION=1 make setup-git
  154. script:
  155. # black is going to rewrite the files in-place.
  156. # i need to either define a second hook that only runs --check --diff and conditionally run that,
  157. # or i need to figure out how to pass additional args to a hook from the pre-commit invocation.
  158. - pre-commit run --all-files
  159. # If pre-commit was good, then we scan dependencies.
  160. # Note that this isn't moved to an after_script since that would override what we already have.
  161. # XXX: ideally we don't have to install sentry in its entirety just to scan dependencies...
  162. # see the note in bin/scan on why this needs to be done for now.
  163. # Note that this will mostly noop because we pull in a cached venv from Travis.
  164. - SENTRY_LIGHT_BUILD=1 SENTRY_PYTHON3=1 pip install -e .
  165. - pip install safety
  166. # XXX: fun fact, as of April 2020 travis preinstalls numpy 1.15.4 in their 3.7 environments
  167. # and the safety scanner won't like that (safety id 36810)
  168. # Previously we had 36810 ignored in bin/scan until it was removed because it was fixed in
  169. # travis 2.7. So this is isolated to at least travis 3.7.
  170. - pip uninstall -y numpy
  171. - bin/scan
  172. - <<: *postgres_default
  173. name: 'Backend with migrations [Postgres] (1/2)'
  174. env: TEST_SUITE=postgres DB=postgres TOTAL_TEST_GROUPS=2 TEST_GROUP=0 MIGRATIONS_TEST_MIGRATE=1
  175. - <<: *postgres_default
  176. name: 'Backend with migrations [Postgres] (2/2)'
  177. env: TEST_SUITE=postgres DB=postgres TOTAL_TEST_GROUPS=2 TEST_GROUP=1 MIGRATIONS_TEST_MIGRATE=1
  178. - <<: *acceptance_default
  179. name: 'Acceptance'
  180. env: TEST_SUITE=acceptance USE_SNUBA=1
  181. - <<: *acceptance_default
  182. name: 'Plugins'
  183. env: TEST_SUITE=plugins DB=postgres PERCY_TOKEN=${PLUGIN_PERCY_TOKEN}
  184. - python: 2.7
  185. name: 'Frontend [test]'
  186. env: TEST_SUITE=js
  187. before_install:
  188. - find "$NODE_DIR" -type d -empty -delete
  189. - nvm install
  190. install:
  191. - ./bin/yarn install --frozen-lockfile
  192. - python: 2.7
  193. name: 'Frontend [build]'
  194. env: TEST_SUITE=js-build
  195. before_install:
  196. - find "$NODE_DIR" -type d -empty -delete
  197. - nvm install
  198. install:
  199. - ./bin/yarn install --frozen-lockfile
  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 .
  209. before_script:
  210. - psql -c 'create database sentry;' -U postgres
  211. - <<: *postgres_default
  212. name: 'Symbolicator Integration'
  213. env: TEST_SUITE=symbolicator
  214. before_install:
  215. - *base_install
  216. - *start_snuba
  217. - docker run -d --network host --name symbolicator us.gcr.io/sentryio/symbolicator:latest run
  218. - docker ps -a
  219. - <<: *postgres_default
  220. name: 'Sentry-Relay integration tests'
  221. env: TEST_SUITE=relay-integration DB=postgres
  222. services:
  223. - docker
  224. - memcached
  225. - redis-server
  226. - postgresql
  227. before_install:
  228. - *base_install
  229. - *start_snuba
  230. - docker pull us.gcr.io/sentryio/relay:latest # pull relay we'll run and kill it for each test
  231. - docker ps -a
  232. - python: 2.7
  233. name: 'Snuba Integration with migrations'
  234. env: TEST_SUITE=snuba USE_SNUBA=1 MIGRATIONS_TEST_MIGRATE=1
  235. services:
  236. - docker
  237. - memcached
  238. - redis-server
  239. - postgresql
  240. before_install:
  241. - *base_install
  242. - *start_snuba
  243. - docker ps -a
  244. install:
  245. - python setup.py install_egg_info
  246. - pip install -U -e ".[dev]"
  247. before_script:
  248. - psql -c 'create database sentry;' -U postgres
  249. # XXX: this needs to be the same as postgres_default (other than python, name, env, and the rb package override)
  250. # NOTE: Migrations need to also be ported to py3.6, but the errors just clog up everything.
  251. # So for now, we're unblocking that by not having MIGRATIONS_TEST_MIGRATE=1.
  252. # Allowed to fail!
  253. # - python: 3.6
  254. # name: 'Python 3.6 backend (no migrations) [Postgres]'
  255. # env: TEST_SUITE=postgres DB=postgres SENTRY_PYTHON3=1 PYTEST_ADDOPTS="" PYTEST_SENTRY_ALWAYS_REPORT=no
  256. # services:
  257. # - memcached
  258. # - redis-server
  259. # - postgresql
  260. # before_install:
  261. # - *base_install
  262. # - *start_snuba
  263. # - docker ps -a
  264. # install:
  265. # - python setup.py install_egg_info
  266. # - pip install -U -e ".[dev]"
  267. # - pip uninstall -y rb
  268. # - pip install -e git+https://github.com/joshuarli/rb.git@505ad7665baba66c7c492b01b0e83d433ed2eb8e#egg=rb
  269. # before_script:
  270. # - psql -c 'create database sentry;' -U postgres
  271. # Deploy 'storybook' (component & style guide)
  272. - name: 'Storybook Deploy'
  273. language: node_js
  274. env: STORYBOOK_BUILD=1
  275. before_install:
  276. # travis pyenv will attempt to use .python-version, but the appropriate python version won't be installed.
  277. # since we don't need python here, we have to remove this.
  278. - rm .python-version
  279. install: ./bin/yarn install --frozen-lockfile
  280. script: ./bin/yarn run storybook-build
  281. after_success: .travis/deploy-storybook.sh
  282. after_failure: skip
  283. notifications:
  284. webhooks:
  285. urls:
  286. - https://zeus.ci/hooks/fa079cf6-8e6b-11e7-9155-0a580a28081c/public/provider/travis/webhook
  287. on_success: always
  288. on_failure: always
  289. on_start: always
  290. on_cancel: always
  291. on_error: always