python.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 }}