action.yml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. # NOTE: Do not rely on `make` commands here as this action is used across different repos
  2. # where the Makefile will not be available
  3. name: 'Sentry Setup'
  4. description: 'Sets up a Sentry test environment'
  5. inputs:
  6. workdir:
  7. description: 'Directory where the sentry source is located'
  8. required: false
  9. default: '.'
  10. snuba:
  11. description: 'Is snuba required?'
  12. required: false
  13. default: 'false'
  14. clickhouse:
  15. description: 'Is clickhouse required?'
  16. required: false
  17. default: 'false'
  18. kafka:
  19. description: 'Is kafka required?'
  20. required: false
  21. default: 'false'
  22. chartcuterie:
  23. description: 'Is chartcuterie required?'
  24. required: false
  25. default: 'false'
  26. bigtable:
  27. description: 'Is bigtable required?'
  28. required: false
  29. default: 'false'
  30. redis_cluster:
  31. description: 'Is redis cluster required?'
  32. required: false
  33. default: 'false'
  34. symbolicator:
  35. description: 'Is symbolicator required?'
  36. required: false
  37. default: 'false'
  38. python-version:
  39. description: 'python version to install'
  40. required: false
  41. default: '3.12.6'
  42. pg-version:
  43. description: 'PostgreSQL version to use'
  44. default: '14'
  45. required: false
  46. use-new-devservices:
  47. description: 'Use new devservices'
  48. required: false
  49. default: 'false'
  50. mode:
  51. description: 'Mode to bring up by new devservices'
  52. required: false
  53. default: 'default'
  54. outputs:
  55. yarn-cache-dir:
  56. description: 'Path to yarn cache'
  57. value: ${{ steps.config.outputs.yarn-cache-dir }}
  58. matrix-instance-number:
  59. description: 'The matrix instance number (starting at 1)'
  60. value: ${{ steps.config.outputs.matrix-instance-number }}
  61. matrix-instance-total:
  62. description: 'Reexport of MATRIX_INSTANCE_TOTAL.'
  63. value: ${{ steps.config.outputs.matrix-instance-total }}
  64. runs:
  65. using: 'composite'
  66. steps:
  67. - name: Setup default environment variables
  68. # the default for "bash" is:
  69. # bash --noprofile --norc -eo pipefail {0}
  70. shell: bash --noprofile --norc -eo pipefail -ux {0}
  71. env:
  72. MATRIX_INSTANCE: ${{ matrix.instance }}
  73. # XXX: We should be using something like len(strategy.matrix.instance) (not possible atm)
  74. # If you have other things like python-version: [foo, bar, baz] then the sharding logic
  75. # isn't right because job-total will be 3x larger and you'd never run 2/3 of the tests.
  76. # MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }}
  77. run: |
  78. echo "PIP_DISABLE_PIP_VERSION_CHECK=on" >> $GITHUB_ENV
  79. echo "PIP_INDEX_URL=https://pypi.devinfra.sentry.io/simple" >> $GITHUB_ENV
  80. echo "SENTRY_SKIP_BACKEND_VALIDATION=1" >> $GITHUB_ENV
  81. ### node configuration ###
  82. echo "NODE_ENV=development" >> $GITHUB_ENV
  83. ### pytest configuration ###
  84. echo "PY_COLORS=1" >> "$GITHUB_ENV"
  85. echo "PYTEST_ADDOPTS=--reruns=5 --durations=10 --fail-slow=60s" >> $GITHUB_ENV
  86. echo "COVERAGE_CORE=sysmon" >> "$GITHUB_ENV"
  87. ### pytest-sentry configuration ###
  88. if [ "$GITHUB_REPOSITORY" = "getsentry/sentry" ]; then
  89. echo "PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079" >> $GITHUB_ENV
  90. echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV
  91. # This records failures on master to sentry in order to detect flakey tests, as it's
  92. # expected that people have failing tests on their PRs
  93. if [ "$GITHUB_REF" = "refs/heads/master" ]; then
  94. echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV
  95. fi
  96. fi
  97. # Configure a different release version, otherwise it defaults to the
  98. # commit sha which will conflict with our actual prod releases. This is a
  99. # confusing experience because it looks like these are "empty" releases
  100. # because no commits are attached and associates the release with our
  101. # javascript + sentry projects.
  102. echo "SENTRY_RELEASE=ci@$GITHUB_SHA" >> $GITHUB_ENV
  103. # this handles pytest test sharding
  104. if [ "$MATRIX_INSTANCE" ]; then
  105. if ! [ "${MATRIX_INSTANCE_TOTAL:-}" ]; then
  106. echo "MATRIX_INSTANCE_TOTAL is required."
  107. exit 1
  108. fi
  109. echo "TEST_GROUP=$MATRIX_INSTANCE" >> $GITHUB_ENV
  110. echo "TOTAL_TEST_GROUPS=$MATRIX_INSTANCE_TOTAL" >> $GITHUB_ENV
  111. fi
  112. - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0
  113. with:
  114. python-version: ${{ inputs.python-version }}
  115. cache-dependency-path: ${{ inputs.workdir }}/requirements-dev-frozen.txt
  116. install-cmd: cd ${{ inputs.workdir }} && pip install -r requirements-dev-frozen.txt
  117. - name: Set up outputs
  118. id: config
  119. env:
  120. MATRIX_INSTANCE: ${{ matrix.instance }}
  121. shell: bash --noprofile --norc -eo pipefail -ux {0}
  122. run: |
  123. echo "yarn-cache-dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
  124. echo "matrix-instance-number=$(($MATRIX_INSTANCE+1))" >> "$GITHUB_OUTPUT"
  125. echo "matrix-instance-total=$((${MATRIX_INSTANCE_TOTAL:-}))" >> "$GITHUB_OUTPUT"
  126. - name: Install python dependencies
  127. shell: bash --noprofile --norc -eo pipefail -ux {0}
  128. env:
  129. # This is necessary when other repositories (e.g. relay) want to take advantage of this workflow
  130. # without needing to fork it. The path needed is the one where setup.py is located
  131. WORKDIR: ${{ inputs.workdir }}
  132. run: |
  133. cd "$WORKDIR"
  134. # We need to install editable otherwise things like check migration will fail.
  135. python3 -m tools.fast_editable --path .
  136. - name: Start devservices
  137. shell: bash --noprofile --norc -eo pipefail -ux {0}
  138. if: ${{ inputs.use-new-devservices != 'true' }}
  139. env:
  140. NEED_KAFKA: ${{ inputs.kafka }}
  141. NEED_SNUBA: ${{ inputs.snuba }}
  142. NEED_CLICKHOUSE: ${{ inputs.clickhouse }}
  143. NEED_BIGTABLE: ${{ inputs.bigtable }}
  144. NEED_CHARTCUTERIE: ${{ inputs.chartcuterie }}
  145. NEED_REDIS_CLUSTER: ${{ inputs.redis_cluster }}
  146. NEED_SYMBOLICATOR: ${{ inputs.symbolicator }}
  147. WORKDIR: ${{ inputs.workdir }}
  148. PG_VERSION: ${{ inputs.pg-version }}
  149. ENABLE_AUTORUN_MIGRATION_SEARCH_ISSUES: '1'
  150. run: |
  151. sentry init
  152. # redis, postgres are needed for almost every code path.
  153. services=(redis postgres)
  154. if [ "$NEED_CLICKHOUSE" = "true" ] || [ "$NEED_SNUBA" = "true" ]; then
  155. services+=(clickhouse)
  156. fi
  157. if [ "$NEED_SNUBA" = "true" ]; then
  158. services+=(snuba)
  159. fi
  160. if [ "$NEED_BIGTABLE" = "true" ]; then
  161. echo "BIGTABLE_EMULATOR_HOST=127.0.0.1:8086" >> $GITHUB_ENV
  162. services+=(bigtable)
  163. fi
  164. if [ "$NEED_CHARTCUTERIE" = "true" ]; then
  165. services+=(chartcuterie)
  166. fi
  167. if [ "$NEED_REDIS_CLUSTER" = "true" ]; then
  168. services+=(redis-cluster)
  169. fi
  170. if [ "$NEED_SYMBOLICATOR" = "true" ]; then
  171. services+=(symbolicator)
  172. fi
  173. if [ "$NEED_KAFKA" = "true" ]; then
  174. services+=(kafka)
  175. fi
  176. sentry devservices up "${services[@]}"
  177. # have tests listen on the docker gateway ip so loopback can occur
  178. echo "DJANGO_LIVE_TEST_SERVER_ADDRESS=$(docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}')" >> "$GITHUB_ENV"
  179. docker ps -a
  180. # This is necessary when other repositories (e.g. relay) want to take advantage of this workflow
  181. # without needing to fork it. The path needed is the one where tools are located
  182. cd "$WORKDIR"
  183. - name: Start new devservices
  184. if: ${{ inputs.use-new-devservices == 'true' }}
  185. shell: bash --noprofile --norc -eo pipefail -ux {0}
  186. env:
  187. WORKDIR: ${{ inputs.workdir }}
  188. ENABLE_AUTORUN_MIGRATION_SEARCH_ISSUES: '1'
  189. run: |
  190. sentry init
  191. # This is necessary to bring up devservices with appropriate sentry config
  192. cd "$WORKDIR"
  193. devservices up --mode ${{ inputs.mode }}
  194. # have tests listen on the docker gateway ip so loopback can occur
  195. echo "DJANGO_LIVE_TEST_SERVER_ADDRESS=$(docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}')" >> "$GITHUB_ENV"
  196. docker ps -a