python.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. name: python
  2. on:
  3. pull_request:
  4. paths:
  5. # Matches all python files regardless of directory depth.
  6. - '**.py'
  7. - requirements*.txt
  8. jobs:
  9. check-missing-migration:
  10. name: Check Migration Required
  11. runs-on: ubuntu-16.04
  12. env:
  13. PIP_DISABLE_PIP_VERSION_CHECK: on
  14. SENTRY_LIGHT_BUILD: 1
  15. SENTRY_SKIP_BACKEND_VALIDATION: 1
  16. MIGRATIONS_TEST_MIGRATE: 0
  17. # The hostname used to communicate with the PostgreSQL from sentry
  18. DATABASE_URL: postgresql://postgres:postgres@localhost/sentry
  19. services:
  20. postgres:
  21. image: postgres:9.6
  22. env:
  23. POSTGRES_USER: postgres
  24. POSTGRES_PASSWORD: postgres
  25. ports:
  26. # Maps tcp port 5432 on service container to the host
  27. - 5432:5432
  28. # needed because the postgres container does not provide a healthcheck
  29. options: >-
  30. --health-cmd pg_isready
  31. --health-interval 10s
  32. --health-timeout 5s
  33. --health-retries 5
  34. steps:
  35. - name: Install System Dependencies
  36. run: |
  37. sudo apt-get update
  38. sudo apt-get install -y --no-install-recommends \
  39. libxmlsec1-dev \
  40. libmaxminddb-dev
  41. # Checkout codebase
  42. - uses: actions/checkout@v2
  43. # Python
  44. # Use `.python-version` to avoid duplication
  45. # XXX: can't actually read from .python-version because GitHub Actions
  46. # does not support our version (2.7.16)
  47. #
  48. # XXX: Using `2.7` as GHA image only seems to keep one minor version around and will break
  49. # CI if we pin it to a specific patch version.
  50. - name: Set up outputs
  51. id: config
  52. env:
  53. MATRIX_INSTANCE: ${{ matrix.instance }}
  54. run: |
  55. echo "::set-output name=python-version::2.7"
  56. # setup python
  57. - name: Set up Python ${{ steps.config.outputs.python-version }}
  58. uses: actions/setup-python@v1
  59. with:
  60. python-version: ${{ steps.config.outputs.python-version}}
  61. # setup pip
  62. - name: Install pip
  63. run: |
  64. pip install --no-cache-dir --upgrade "pip>=20.0.2"
  65. # pip cache
  66. - name: Get pip cache dir
  67. id: pip-cache
  68. run: |
  69. echo "::set-output name=dir::$(pip cache dir)"
  70. - name: pip cache
  71. uses: actions/cache@v1
  72. with:
  73. path: ${{ steps.pip-cache.outputs.dir }}
  74. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  75. restore-keys: |
  76. ${{ runner.os }}-pip-
  77. - name: Install Python Dependencies
  78. env:
  79. PGPASSWORD: postgres
  80. run: |
  81. python setup.py install_egg_info
  82. pip install wheel # GitHub Actions does not have this installed by default (unlike Travis)
  83. pip install -U -e ".[dev]"
  84. psql -c 'create database sentry;' -h localhost -U postgres
  85. sentry init
  86. - name: Check if a migration is required
  87. env:
  88. SENTRY_LOG_LEVEL: ERROR
  89. PGPASSWORD: postgres
  90. run: |
  91. # Below will exit with non-zero status if model changes are missing migrations
  92. sentry django makemigrations -n ci_test --check --dry-run --no-input || (echo '::error::Error: Migration required -- to generate a migration, run `sentry django makemigrations -n <some_name>`' && exit 1)
  93. test-py3:
  94. name: 'py3 [ignore fails]'
  95. runs-on: ubuntu-16.04
  96. continue-on-error: true
  97. strategy:
  98. matrix:
  99. instance: [0, 1, 2, 3]
  100. env:
  101. SENTRY_PYTHON3: 1
  102. PIP_DISABLE_PIP_VERSION_CHECK: on
  103. SENTRY_LIGHT_BUILD: 1
  104. SENTRY_SKIP_BACKEND_VALIDATION: 1
  105. PYTEST_SENTRY_DSN: https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079
  106. # XXX(py3): Reruns are disabled for until all tests are passing.
  107. PYTEST_ADDOPTS: ""
  108. PYTEST_SENTRY_ALWAYS_REPORT: no
  109. # services configuration
  110. SENTRY_REDIS_HOST: redis
  111. DATABASE_URL: postgresql://postgres:postgres@localhost/sentry
  112. # Number of matrix instances
  113. TOTAL_TEST_GROUPS: ${{ strategy.job-total }}
  114. steps:
  115. - name: Install System Dependencies
  116. run: |
  117. sudo apt-get update
  118. sudo apt-get install -y --no-install-recommends \
  119. libxmlsec1-dev \
  120. libmaxminddb-dev
  121. - uses: actions/checkout@v2
  122. - name: Set up outputs
  123. id: config
  124. env:
  125. MATRIX_INSTANCE: ${{ matrix.instance }}
  126. run: |
  127. # XXX(py3): Minors that aren't latest seem to not be available.
  128. echo "::set-output name=python-version::3.6.12"
  129. echo "::set-output name=matrix-instance-number::$(($MATRIX_INSTANCE+1))"
  130. - name: Set up Python ${{ steps.config.outputs.python-version }}
  131. uses: actions/setup-python@v1
  132. with:
  133. python-version: ${{ steps.config.outputs.python-version}}
  134. - name: Install pip
  135. run: |
  136. pip install --no-cache-dir --upgrade "pip>=20.0.2"
  137. - name: Get pip cache dir
  138. id: pip-cache
  139. run: |
  140. echo "::set-output name=dir::$(pip cache dir)"
  141. - name: pip cache
  142. uses: actions/cache@v1
  143. with:
  144. path: ${{ steps.pip-cache.outputs.dir }}
  145. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  146. restore-keys: |
  147. ${{ runner.os }}-pip-
  148. - name: Install Python Dependencies
  149. env:
  150. PGPASSWORD: postgres
  151. run: |
  152. python setup.py install_egg_info
  153. pip install wheel # GitHub Actions does not have this installed by default (unlike Travis)
  154. pip install -U -e ".[dev]"
  155. # XXX: wasn't able to get this working in requirements_base.
  156. # It's possible if you're installing via -r but it breaks -e.
  157. pip uninstall -y rb
  158. pip install -e git+https://github.com/getsentry/rb.git@master#egg=rb
  159. - name: Start devservices
  160. run: |
  161. sentry init
  162. sentry devservices up postgres redis clickhouse snuba
  163. # When we have a full backend test matrix for py3, make a py2 one with new rb as well.
  164. # TODO(joshuarli):
  165. # - kakfa+zookeeper devservices necessary for what test suites?
  166. # - is `docker exec sentry_snuba snuba migrate` needed?
  167. # - MIGRATIONS_TEST_MIGRATE=1
  168. # - TEST_SUITE=relay-integration
  169. # - TEST_SUITE=symbolicator
  170. # - TEST_SUITE=cli
  171. - name: Python 3.6 backend w/o migrations (${{ steps.config.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  172. if: always()
  173. run: |
  174. make travis-test-postgres
  175. env:
  176. TEST_GROUP: ${{ matrix.instance }}
  177. test-py3-snuba:
  178. name: 'py3 snuba [ignore fails]'
  179. runs-on: ubuntu-16.04
  180. continue-on-error: true
  181. strategy:
  182. matrix:
  183. instance: [0]
  184. env:
  185. SENTRY_PYTHON3: 1
  186. PIP_DISABLE_PIP_VERSION_CHECK: on
  187. USE_SNUBA: 1
  188. SENTRY_LIGHT_BUILD: 1
  189. SENTRY_SKIP_BACKEND_VALIDATION: 1
  190. PYTEST_SENTRY_DSN: https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079
  191. # XXX(py3): Reruns are disabled for until all tests are passing.
  192. PYTEST_ADDOPTS: ""
  193. PYTEST_SENTRY_ALWAYS_REPORT: no
  194. # services configuration
  195. SENTRY_REDIS_HOST: redis
  196. DATABASE_URL: postgresql://postgres:postgres@localhost/sentry
  197. SENTRY_KAFKA_HOSTS: localhost:9092
  198. SENTRY_ZOOKEEPER_HOSTS: localhost:2181
  199. # Number of matrix instances
  200. TOTAL_TEST_GROUPS: ${{ strategy.job-total }}
  201. steps:
  202. - name: Install System Dependencies
  203. run: |
  204. sudo apt-get update
  205. sudo apt-get install -y --no-install-recommends \
  206. libxmlsec1-dev \
  207. libmaxminddb-dev
  208. - uses: actions/checkout@v2
  209. - name: Set up outputs
  210. id: config
  211. env:
  212. MATRIX_INSTANCE: ${{ matrix.instance }}
  213. run: |
  214. # XXX(py3): Minors that aren't latest seem to not be available.
  215. echo "::set-output name=python-version::3.6.12"
  216. echo "::set-output name=matrix-instance-number::$(($MATRIX_INSTANCE+1))"
  217. - name: Set up Python ${{ steps.config.outputs.python-version }}
  218. uses: actions/setup-python@v1
  219. with:
  220. python-version: ${{ steps.config.outputs.python-version}}
  221. - name: Install pip
  222. run: |
  223. pip install --no-cache-dir --upgrade "pip>=20.0.2"
  224. - name: Get pip cache dir
  225. id: pip-cache
  226. run: |
  227. echo "::set-output name=dir::$(pip cache dir)"
  228. - name: pip cache
  229. uses: actions/cache@v1
  230. with:
  231. path: ${{ steps.pip-cache.outputs.dir }}
  232. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  233. restore-keys: |
  234. ${{ runner.os }}-pip-
  235. - name: Install Python Dependencies
  236. env:
  237. PGPASSWORD: postgres
  238. run: |
  239. python setup.py install_egg_info
  240. pip install wheel # GitHub Actions does not have this installed by default (unlike Travis)
  241. pip install -U -e ".[dev]"
  242. # XXX: wasn't able to get this working in requirements_base.
  243. # It's possible if you're installing via -r but it breaks -e.
  244. pip uninstall -y rb
  245. pip install -e git+https://github.com/getsentry/rb.git@master#egg=rb
  246. - name: Start devservices
  247. run: |
  248. sentry init
  249. docker run \
  250. --name sentry_zookeeper \
  251. -d --network host \
  252. -e ZOOKEEPER_CLIENT_PORT=2181 \
  253. confluentinc/cp-zookeeper:4.1.0
  254. docker run \
  255. --name sentry_kafka \
  256. -d --network host \
  257. -e KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
  258. -e KAFKA_LISTENERS=INTERNAL://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092 \
  259. -e KAFKA_ADVERTISED_LISTENERS=INTERNAL://127.0.0.1:9093,EXTERNAL://127.0.0.1:9092 \
  260. -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT \
  261. -e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL \
  262. -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  263. confluentinc/cp-kafka:5.1.2
  264. sentry devservices up postgres redis clickhouse snuba
  265. - name: Python 3.6 snuba backend w/o migrations (${{ steps.config.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  266. if: always()
  267. run: |
  268. make travis-test-snuba
  269. env:
  270. TEST_GROUP: ${{ matrix.instance }}