python.yml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. name: python
  2. on:
  3. push:
  4. branches:
  5. - master
  6. - releases/**
  7. pull_request:
  8. paths:
  9. # Matches all python files regardless of directory depth.
  10. - '**.py'
  11. - requirements*.txt
  12. jobs:
  13. check-missing-migration:
  14. # Not necessary for this job to run on the push branches.
  15. if: ${{ github.ref != 'refs/heads/master' || contains(github.ref, 'releases/') }}
  16. name: Check Migration Required
  17. runs-on: ubuntu-16.04
  18. env:
  19. PIP_DISABLE_PIP_VERSION_CHECK: on
  20. SENTRY_LIGHT_BUILD: 1
  21. SENTRY_SKIP_BACKEND_VALIDATION: 1
  22. MIGRATIONS_TEST_MIGRATE: 0
  23. # The hostname used to communicate with the PostgreSQL from sentry
  24. DATABASE_URL: postgresql://postgres:postgres@localhost/sentry
  25. services:
  26. postgres:
  27. image: postgres:9.6
  28. env:
  29. POSTGRES_USER: postgres
  30. POSTGRES_PASSWORD: postgres
  31. ports:
  32. # Maps tcp port 5432 on service container to the host
  33. - 5432:5432
  34. # needed because the postgres container does not provide a healthcheck
  35. options: >-
  36. --health-cmd pg_isready
  37. --health-interval 10s
  38. --health-timeout 5s
  39. --health-retries 5
  40. steps:
  41. - name: Install System Dependencies
  42. run: |
  43. sudo apt-get update
  44. sudo apt-get install -y --no-install-recommends \
  45. libxmlsec1-dev \
  46. libmaxminddb-dev
  47. - uses: actions/checkout@v2
  48. - name: Set up outputs
  49. id: config
  50. env:
  51. MATRIX_INSTANCE: ${{ matrix.instance }}
  52. run: |
  53. echo "::set-output name=python-version::2.7.17"
  54. - name: Set up Python ${{ steps.config.outputs.python-version }}
  55. uses: actions/setup-python@v2
  56. with:
  57. python-version: ${{ steps.config.outputs.python-version}}
  58. - name: Setup pip
  59. uses: ./.github/actions/setup-pip
  60. id: pip
  61. - name: pip cache
  62. uses: actions/cache@v2
  63. with:
  64. path: ${{ steps.pip.outputs.pip-cache-dir }}
  65. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-*.txt') }}
  66. restore-keys: |
  67. ${{ runner.os }}-pip-
  68. - name: Install Python Dependencies
  69. env:
  70. PGPASSWORD: postgres
  71. run: |
  72. python setup.py install_egg_info
  73. pip install wheel # GitHub Actions does not have this installed by default (unlike Travis)
  74. pip install -U -e ".[dev]"
  75. psql -c 'create database sentry;' -h localhost -U postgres
  76. sentry init
  77. - name: Check if a migration is required
  78. env:
  79. SENTRY_LOG_LEVEL: ERROR
  80. PGPASSWORD: postgres
  81. run: |
  82. # Below will exit with non-zero status if model changes are missing migrations
  83. 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)
  84. test-py3:
  85. name: 'python3.6 backend'
  86. runs-on: ubuntu-16.04
  87. timeout-minutes: 30
  88. strategy:
  89. matrix:
  90. instance: [0, 1, 2]
  91. env:
  92. MIGRATIONS_TEST_MIGRATE: 1
  93. steps:
  94. - uses: actions/checkout@v2
  95. - uses: volta-cli/action@v1
  96. - name: Set python version output
  97. id: python-version
  98. run: |
  99. echo "::set-output name=python-version::$(awk 'FNR == 2' .python-version)"
  100. # Until GH composite actions can use `uses`, we need to setup python here
  101. - uses: actions/setup-python@v2
  102. with:
  103. python-version: ${{ steps.python-version.outputs.python-version }}
  104. - name: Setup pip
  105. uses: ./.github/actions/setup-pip
  106. id: pip
  107. - name: pip cache
  108. uses: actions/cache@v2
  109. with:
  110. path: ${{ steps.pip.outputs.pip-cache-dir }}
  111. key: ${{ runner.os }}-pip-py${{ steps.python-version.outputs.python-version }}-${{ hashFiles('**/requirements-*.txt') }}
  112. restore-keys: |
  113. ${{ runner.os }}-pip-py${{ steps.python-version.outputs.python-version }}
  114. - name: Setup sentry env
  115. uses: ./.github/actions/setup-sentry
  116. id: setup
  117. with:
  118. python: 3
  119. - name: Python 3.6 backend (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  120. if: always()
  121. run: |
  122. make travis-test-postgres
  123. test-py3-snuba:
  124. name: '[ignore fails] python3.6 backend (snuba)'
  125. runs-on: ubuntu-16.04
  126. continue-on-error: true
  127. timeout-minutes: 30
  128. strategy:
  129. matrix:
  130. instance: [0]
  131. env:
  132. # Note: `USE_SNUBA` is only used for the Snuba test suite because we have some failing acceptance tests with Snuba enabled.
  133. USE_SNUBA: 1
  134. MIGRATIONS_TEST_MIGRATE: 1
  135. steps:
  136. - uses: actions/checkout@v2
  137. - uses: volta-cli/action@v1
  138. - name: Set python version output
  139. id: python-version
  140. run: |
  141. echo "::set-output name=python-version::$(awk 'FNR == 2' .python-version)"
  142. # Until GH composite actions can use `uses`, we need to setup python here
  143. - uses: actions/setup-python@v2
  144. with:
  145. python-version: ${{ steps.python-version.outputs.python-version }}
  146. - name: Setup pip
  147. uses: ./.github/actions/setup-pip
  148. id: pip
  149. - name: pip cache
  150. uses: actions/cache@v2
  151. with:
  152. path: ${{ steps.pip.outputs.pip-cache-dir }}
  153. key: ${{ runner.os }}-pip-py${{ steps.python-version.outputs.python-version }}-${{ hashFiles('**/requirements-*.txt') }}
  154. restore-keys: |
  155. ${{ runner.os }}-pip-py${{ steps.python-version.outputs.python-version }}
  156. - name: Setup sentry env
  157. uses: ./.github/actions/setup-sentry
  158. id: setup
  159. with:
  160. python: 3
  161. kafka: true
  162. - name: Python 3.6 snuba backend (${{ steps.setup.outputs.matrix-instance-number }} of ${{ strategy.job-total }})
  163. if: always()
  164. run: |
  165. make travis-test-snuba