test_devservices_backend.yml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. name: test-devservices-backend
  2. on:
  3. schedule:
  4. - cron: '0 * * * *'
  5. # Cancel in progress workflows on pull_requests.
  6. # https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
  7. concurrency:
  8. group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  9. cancel-in-progress: true
  10. # hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
  11. env:
  12. SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
  13. USE_NEW_DEVSERVICES: 1
  14. IS_DEV: 1
  15. jobs:
  16. devservices-api-docs:
  17. name: api docs test
  18. runs-on: ubuntu-24.04
  19. steps:
  20. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  21. - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
  22. id: setup-node
  23. with:
  24. node-version-file: '.volta.json'
  25. - name: Setup sentry python env
  26. uses: ./.github/actions/test-setup-sentry-devservices
  27. id: setup
  28. - name: Bring up devservices
  29. run: devservices up
  30. - name: Run API docs tests
  31. # install ts-node for ts build scripts to execute properly without potentially installing
  32. # conflicting deps when running scripts locally
  33. # see: https://github.com/getsentry/sentry/pull/32328/files
  34. run: |
  35. yarn add ts-node && make test-api-docs
  36. - name: Inspect failure
  37. if: failure()
  38. run: devservices logs
  39. devservices-backend-test:
  40. name: backend test
  41. runs-on: ubuntu-24.04
  42. timeout-minutes: 60
  43. permissions:
  44. contents: read
  45. id-token: write
  46. strategy:
  47. # This helps not having to run multiple jobs because one fails, thus, reducing resource usage
  48. # and reducing the risk that one of many runs would turn red again (read: intermittent tests)
  49. fail-fast: false
  50. matrix:
  51. # XXX: When updating this, make sure you also update MATRIX_INSTANCE_TOTAL.
  52. instance: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  53. pg-version: ['14']
  54. env:
  55. # XXX: `MATRIX_INSTANCE_TOTAL` must be hardcoded to the length of `strategy.matrix.instance`.
  56. # If this increases, make sure to also increase `flags.backend.after_n_builds` in `codecov.yml`.
  57. MATRIX_INSTANCE_TOTAL: 11
  58. steps:
  59. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  60. - name: Setup sentry env
  61. id: setup
  62. uses: ./.github/actions/test-setup-sentry-devservices
  63. - name: Bring up devservices
  64. run: devservices up --mode backend-ci
  65. - name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
  66. run: |
  67. make test-python-ci
  68. - name: Collect test data
  69. uses: ./.github/actions/collect-test-data
  70. if: ${{ !cancelled() }}
  71. with:
  72. artifact_path: .artifacts/pytest.json
  73. gcs_bucket: ${{ secrets.COLLECT_TEST_DATA_GCS_BUCKET }}
  74. gcp_project_id: ${{ secrets.COLLECT_TEST_DATA_GCP_PROJECT_ID }}
  75. workload_identity_provider: ${{ secrets.SENTRY_GCP_DEV_WORKLOAD_IDENTITY_POOL }}
  76. service_account_email: ${{ secrets.COLLECT_TEST_DATA_SERVICE_ACCOUNT_EMAIL }}
  77. matrix_instance_number: ${{ steps.setup.outputs.matrix-instance-number }}
  78. # Upload coverage data even if running the tests step fails since
  79. # it reduces large coverage fluctuations
  80. - name: Handle artifacts
  81. if: ${{ always() }}
  82. uses: ./.github/actions/artifacts
  83. with:
  84. token: ${{ secrets.CODECOV_TOKEN }}
  85. commit_sha: ${{ github.event.pull_request.head.sha }}
  86. - name: Inspect failure
  87. if: failure()
  88. run: devservices logs
  89. devservices-backend-migration-tests:
  90. name: backend migration tests
  91. runs-on: ubuntu-24.04
  92. timeout-minutes: 30
  93. strategy:
  94. matrix:
  95. pg-version: ['14']
  96. steps:
  97. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  98. - name: Setup sentry env
  99. uses: ./.github/actions/test-setup-sentry-devservices
  100. id: setup
  101. - name: Bring up devservices
  102. run: devservices up
  103. - name: run tests
  104. run: |
  105. PYTEST_ADDOPTS="$PYTEST_ADDOPTS -m migrations --migrations --reruns 0" make test-python-ci
  106. # Upload coverage data even if running the tests step fails since
  107. # it reduces large coverage fluctuations
  108. - name: Handle artifacts
  109. if: ${{ always() }}
  110. uses: ./.github/actions/artifacts
  111. with:
  112. token: ${{ secrets.CODECOV_TOKEN }}
  113. commit_sha: ${{ github.event.pull_request.head.sha }}
  114. - name: Inspect failure
  115. if: failure()
  116. run: devservices logs
  117. devservices-cli:
  118. name: cli test
  119. runs-on: ubuntu-24.04
  120. timeout-minutes: 10
  121. strategy:
  122. matrix:
  123. pg-version: ['14']
  124. steps:
  125. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  126. - name: Setup sentry env
  127. uses: ./.github/actions/test-setup-sentry-devservices
  128. id: setup
  129. - name: Bring up devservices
  130. run: devservices up --mode migrations
  131. - name: Run test
  132. run: |
  133. make test-cli
  134. # Upload coverage data even if running the tests step fails since
  135. # it reduces large coverage fluctuations
  136. - name: Handle artifacts
  137. if: ${{ always() }}
  138. uses: ./.github/actions/artifacts
  139. with:
  140. token: ${{ secrets.CODECOV_TOKEN }}
  141. commit_sha: ${{ github.event.pull_request.head.sha }}
  142. - name: Inspect failure
  143. if: failure()
  144. run: devservices logs
  145. devservices-migration:
  146. name: check migration
  147. runs-on: ubuntu-24.04
  148. strategy:
  149. matrix:
  150. pg-version: ['14']
  151. steps:
  152. - name: Checkout sentry
  153. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  154. - name: Setup sentry env
  155. uses: ./.github/actions/test-setup-sentry-devservices
  156. id: setup
  157. - name: Bring up devservices
  158. run: devservices up --mode migrations
  159. - name: Migration & lockfile checks
  160. env:
  161. SENTRY_LOG_LEVEL: ERROR
  162. PGPASSWORD: postgres
  163. run: |
  164. ./.github/workflows/scripts/migration-check.sh
  165. - name: Inspect failure
  166. if: failure()
  167. run: devservices logs
  168. devservices-monolith-dbs:
  169. name: monolith-dbs test
  170. runs-on: ubuntu-24.04
  171. timeout-minutes: 20
  172. permissions:
  173. contents: read
  174. id-token: write
  175. steps:
  176. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  177. - name: Setup sentry env
  178. uses: ./.github/actions/test-setup-sentry-devservices
  179. id: setup
  180. - name: Bring up devservices
  181. run: devservices up --mode migrations
  182. - name: Run test
  183. run: |
  184. make test-monolith-dbs
  185. - name: Collect test data
  186. uses: ./.github/actions/collect-test-data
  187. if: ${{ !cancelled() }}
  188. with:
  189. artifact_path: .artifacts/pytest.monolith-dbs.json
  190. gcs_bucket: ${{ secrets.COLLECT_TEST_DATA_GCS_BUCKET }}
  191. gcp_project_id: ${{ secrets.COLLECT_TEST_DATA_GCP_PROJECT_ID }}
  192. workload_identity_provider: ${{ secrets.SENTRY_GCP_DEV_WORKLOAD_IDENTITY_POOL }}
  193. service_account_email: ${{ secrets.COLLECT_TEST_DATA_SERVICE_ACCOUNT_EMAIL }}
  194. # Upload coverage data even if running the tests step fails since
  195. # it reduces large coverage fluctuations
  196. - name: Handle artifacts
  197. if: ${{ always() }}
  198. uses: ./.github/actions/artifacts
  199. with:
  200. token: ${{ secrets.CODECOV_TOKEN }}
  201. commit_sha: ${{ github.event.pull_request.head.sha }}
  202. - name: Inspect failure
  203. if: failure()
  204. run: devservices logs
  205. # This check runs once all dependent jobs have passed
  206. # It symbolizes that all required Backend checks have succesfully passed (Or skipped)
  207. # This step is the only required backend check
  208. devservices-backend-required-check:
  209. needs:
  210. [
  211. devservices-api-docs,
  212. devservices-backend-test,
  213. devservices-backend-migration-tests,
  214. devservices-cli,
  215. devservices-migration,
  216. devservices-monolith-dbs,
  217. ]
  218. name: Devservices Backend
  219. # This is necessary since a failed/skipped dependent job would cause this job to be skipped
  220. if: always()
  221. runs-on: ubuntu-24.04
  222. steps:
  223. # If any jobs we depend on fail, we will fail since this is a required check
  224. # NOTE: A timeout is considered a failure
  225. - name: Check for failures
  226. if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
  227. run: |
  228. echo "One of the dependent jobs have failed. You may need to re-run it." && exit 1