test_docker_compose_backend.yml 10 KB

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