action.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. cache-files-hash:
  27. description: 'A single hash for a set of files. Used for caching.'
  28. required: false
  29. default: ${{ hashFiles('requirements-*.txt', '!requirements-pre-commit.txt') }}
  30. python-version:
  31. description: "python version to install"
  32. required: false
  33. pip-cache-version:
  34. description: 'pip cache version in order to bust cache'
  35. required: false
  36. default: '1630355466247'
  37. outputs:
  38. yarn-cache-dir:
  39. description: "Path to yarn cache"
  40. value: ${{ steps.config.outputs.yarn-cache-dir }}
  41. pip-cache-dir:
  42. description: "Path to pip cache"
  43. value: ${{ steps.setup-python.outputs.pip-cache-dir }}
  44. pip-version:
  45. description: "pip version"
  46. value: ${{ steps.setup-python.outputs.pip-version }}
  47. python-version:
  48. description: "python version"
  49. value: ${{ steps.setup-python.outputs.python-version }}
  50. acceptance-dir:
  51. description: "Path to acceptance visual snapshot artifacts"
  52. value: ${{ steps.config.outputs.acceptance-dir }}
  53. matrix-instance-number:
  54. description: "The matrix instance number (starting at 1)"
  55. value: ${{ steps.config.outputs.matrix-instance-number }}
  56. runs:
  57. using: "composite"
  58. steps:
  59. - name: Setup default environment variables
  60. shell: bash
  61. env:
  62. NEED_KAFKA: ${{ inputs.kafka }}
  63. MATRIX_INSTANCE: ${{ matrix.instance }}
  64. MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }}
  65. run: |
  66. # Only set `MIGRATIONS_TEST_MIGRATE` if it is not already set (or if it's an empty string)
  67. if [ -z $MIGRATIONS_TEST_MIGRATE ]; then
  68. echo "MIGRATIONS_TEST_MIGRATE=0" >> $GITHUB_ENV
  69. fi
  70. echo "PIP_DISABLE_PIP_VERSION_CHECK=on" >> $GITHUB_ENV
  71. echo "SENTRY_LIGHT_BUILD=1" >> $GITHUB_ENV
  72. echo "SENTRY_SKIP_BACKEND_VALIDATION=1" >> $GITHUB_ENV
  73. ### node configuration ###
  74. echo "NODE_ENV=development" >> $GITHUB_ENV
  75. echo "NODE_OPTIONS=--max-old-space-size=4096" >> $GITHUB_ENV
  76. ### pytest-sentry configuration ###
  77. echo "PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079" >> $GITHUB_ENV
  78. echo "PYTEST_ADDOPTS=--reruns 5" >> $GITHUB_ENV
  79. # this handles pytest test sharding
  80. if [ "$MATRIX_INSTANCE" ]; then
  81. echo "TEST_GROUP=$MATRIX_INSTANCE" >> $GITHUB_ENV
  82. echo "TOTAL_TEST_GROUPS=$MATRIX_INSTANCE_TOTAL" >> $GITHUB_ENV
  83. fi
  84. # This records failures on master to sentry in order to detect flakey tests, as it's
  85. # expected that people have failing tests on their PRs
  86. [ "$GITHUB_REF" = "refs/heads/master" ] && echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV || true
  87. ### services configuration ###
  88. echo "BIGTABLE_EMULATOR_HOST=localhost:8086" >> $GITHUB_ENV
  89. # Note: some backend tests (e.g. tests/sentry/eventstream/kafka/test_consumer.py) will behave
  90. # differently if these are set.
  91. if [ "$NEED_KAFKA" = "true" ]; then
  92. echo "SENTRY_KAFKA_HOSTS=127.0.0.1:9092" >> $GITHUB_ENV
  93. echo "SENTRY_ZOOKEEPER_HOSTS=127.0.0.1:2181" >> $GITHUB_ENV
  94. fi
  95. - name: Setup python
  96. id: setup-python
  97. uses: ./.github/actions/setup-python
  98. with:
  99. python-version: ${{ inputs.python-version }}
  100. cache-files-hash: ${{ inputs.cache-files-hash }}
  101. pip-cache-version: ${{ inputs.pip-cache-version }}
  102. workdir: ${{ inputs.workdir }}
  103. - name: Install system dependencies
  104. shell: bash
  105. run: |
  106. sudo apt-get update
  107. sudo apt-get install -y --no-install-recommends \
  108. libxmlsec1-dev \
  109. libmaxminddb-dev
  110. - name: Set up outputs
  111. id: config
  112. env:
  113. MATRIX_INSTANCE: ${{ matrix.instance }}
  114. shell: bash
  115. run: |
  116. echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
  117. echo "::set-output name=matrix-instance-number::$(($MATRIX_INSTANCE+1))"
  118. echo "::set-output name=acceptance-dir::.artifacts/visual-snapshots/acceptance"
  119. - name: Install python dependencies
  120. shell: bash
  121. env:
  122. # This is necessary when other repositories (e.g. relay) want to take advantage of this workflow
  123. # without needing to fork it. The path needed is the one where setup.py is located
  124. WORKDIR: ${{ inputs.workdir }}
  125. run: |
  126. cd "$WORKDIR"
  127. python setup.py install_egg_info
  128. pip install wheel # GitHub Actions does not have `wheel` installed by default
  129. pip install -U -e ".[dev]"
  130. cd -
  131. - name: Start devservices
  132. shell: bash
  133. env:
  134. NEED_KAFKA: ${{ inputs.kafka }}
  135. NEED_SNUBA: ${{ inputs.snuba }}
  136. NEED_CLICKHOUSE: ${{ inputs.clickhouse }}
  137. NEED_CHARTCUTERIE: ${{ inputs.chartcuterie }}
  138. run: |
  139. sentry init
  140. # redis, postgres are needed for almost every code path.
  141. sentry devservices up redis postgres
  142. if [ "$BIGTABLE_EMULATOR_HOST" ]; then
  143. sentry devservices up --skip-only-if bigtable
  144. fi
  145. # TODO: Use devservices kafka. See https://github.com/getsentry/sentry/pull/20986#issuecomment-704510570
  146. if [ "$NEED_KAFKA" = "true" ]; then
  147. docker run \
  148. --name sentry_zookeeper \
  149. -d --network host \
  150. -e ZOOKEEPER_CLIENT_PORT=2181 \
  151. confluentinc/cp-zookeeper:4.1.0
  152. docker run \
  153. --name sentry_kafka \
  154. -d --network host \
  155. -e KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
  156. -e KAFKA_LISTENERS=INTERNAL://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092 \
  157. -e KAFKA_ADVERTISED_LISTENERS=INTERNAL://127.0.0.1:9093,EXTERNAL://127.0.0.1:9092 \
  158. -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT \
  159. -e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL \
  160. -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  161. confluentinc/cp-kafka:5.1.2
  162. fi
  163. if [ "$NEED_SNUBA" = "true" ]; then
  164. sentry devservices up clickhouse snuba
  165. fi
  166. if [ "$NEED_CLICKHOUSE" = "true" ]; then
  167. sentry devservices up clickhouse
  168. fi
  169. if [ "$NEED_CHARTCUTERIE" = "true" ]; then
  170. sentry devservices up --skip-only-if chartcuterie
  171. fi
  172. docker ps -a