test_devservices_backend.yml 8.6 KB

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