action.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. name: 'Sentry Setup'
  2. description: 'Sets up a Sentry test environment'
  3. inputs:
  4. working-dir:
  5. description: 'Directory to do work from'
  6. required: false
  7. default: '.'
  8. snuba:
  9. description: 'Is snuba required?'
  10. required: false
  11. default: 'false'
  12. kafka:
  13. description: 'Is kafka required?'
  14. required: false
  15. default: 'false'
  16. chartcuterie:
  17. description: 'Is chartcuterie required?'
  18. required: false
  19. default: 'false'
  20. outputs:
  21. yarn-cache-dir:
  22. description: "Path to yarn cache"
  23. value: ${{ steps.config.outputs.yarn-cache-dir }}
  24. pip-cache-dir:
  25. description: "Path to pip cache"
  26. value: ${{ steps.pip-cache.outputs.pip-cache }}
  27. acceptance-dir:
  28. description: "Path to acceptance visual snapshot artifacts"
  29. value: ${{ steps.config.outputs.acceptance-dir }}
  30. matrix-instance-number:
  31. description: "The matrix instance number (starting at 1)"
  32. value: ${{ steps.config.outputs.matrix-instance-number }}
  33. runs:
  34. using: "composite"
  35. steps:
  36. - name: Setup default environment variables
  37. shell: bash
  38. env:
  39. NEED_KAFKA: ${{ inputs.kafka }}
  40. MATRIX_INSTANCE: ${{ matrix.instance }}
  41. MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }}
  42. run: |
  43. echo "PIP_DISABLE_PIP_VERSION_CHECK=on" >> $GITHUB_ENV
  44. echo "MIGRATIONS_TEST_MIGRATE=0" >> $GITHUB_ENV
  45. echo "SENTRY_LIGHT_BUILD=1" >> $GITHUB_ENV
  46. echo "SENTRY_SKIP_BACKEND_VALIDATION=1" >> $GITHUB_ENV
  47. ### node configuration ###
  48. echo "NODE_ENV=development" >> $GITHUB_ENV
  49. echo "NODE_OPTIONS=--max-old-space-size=4096" >> $GITHUB_ENV
  50. ### pytest-sentry configuration ###
  51. echo "PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079" >> $GITHUB_ENV
  52. echo "PYTEST_ADDOPTS=--reruns 5" >> $GITHUB_ENV
  53. # this handles pytest test sharding
  54. if [ "$MATRIX_INSTANCE" ]; then
  55. echo "TEST_GROUP=$MATRIX_INSTANCE" >> $GITHUB_ENV
  56. echo "TOTAL_TEST_GROUPS=$MATRIX_INSTANCE_TOTAL" >> $GITHUB_ENV
  57. fi
  58. # This records failures on master to sentry in order to detect flakey tests, as it's
  59. # expected that people have failing tests on their PRs
  60. [ "$GITHUB_REF" = "refs/heads/master" ] && echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV || true
  61. ### services configuration ###
  62. echo "BIGTABLE_EMULATOR_HOST=localhost:8086" >> $GITHUB_ENV
  63. # Note: some backend tests (e.g. tests/sentry/eventstream/kafka/test_consumer.py) will behave
  64. # differently if these are set.
  65. if [ "$NEED_KAFKA" = "true" ]; then
  66. echo "SENTRY_KAFKA_HOSTS=127.0.0.1:9092" >> $GITHUB_ENV
  67. echo "SENTRY_ZOOKEEPER_HOSTS=127.0.0.1:2181" >> $GITHUB_ENV
  68. fi
  69. - name: Install system dependencies
  70. shell: bash
  71. run: |
  72. sudo apt-get update
  73. sudo apt-get install -y --no-install-recommends \
  74. libxmlsec1-dev \
  75. libmaxminddb-dev
  76. - name: Set up outputs
  77. id: config
  78. env:
  79. MATRIX_INSTANCE: ${{ matrix.instance }}
  80. shell: bash
  81. run: |
  82. echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
  83. echo "::set-output name=matrix-instance-number::$(($MATRIX_INSTANCE+1))"
  84. echo "::set-output name=acceptance-dir::.artifacts/visual-snapshots/acceptance"
  85. - name: Install python dependencies
  86. shell: bash
  87. env:
  88. # This is necessary when other repositories (e.g. relay) want to take advantage of this workflow
  89. # without needing to fork it. The path needed is the one where setup.py is located
  90. WORKDIR: ${{ inputs.workdir }}
  91. run: |
  92. cd "$WORKDIR"
  93. python setup.py install_egg_info
  94. pip install wheel # GitHub Actions does not have `wheel` installed by default
  95. pip install -U -e ".[dev]"
  96. # pytest plugin used for better pytest failure annotations
  97. pip install pytest-github-actions-annotate-failures
  98. - name: Start devservices
  99. shell: bash
  100. env:
  101. NEED_KAFKA: ${{ inputs.kafka }}
  102. NEED_SNUBA: ${{ inputs.snuba }}
  103. NEED_CHARTCUTERIE: ${{ inputs.chartcuterie }}
  104. run: |
  105. sentry init
  106. # redis, postgres are needed for almost every code path.
  107. sentry devservices up redis postgres
  108. if [ "$BIGTABLE_EMULATOR_HOST" ]; then
  109. sentry devservices up --skip-only-if bigtable
  110. fi
  111. # TODO: Use devservices kafka. See https://github.com/getsentry/sentry/pull/20986#issuecomment-704510570
  112. if [ "$NEED_KAFKA" = "true" ]; then
  113. docker run \
  114. --name sentry_zookeeper \
  115. -d --network host \
  116. -e ZOOKEEPER_CLIENT_PORT=2181 \
  117. confluentinc/cp-zookeeper:4.1.0
  118. docker run \
  119. --name sentry_kafka \
  120. -d --network host \
  121. -e KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
  122. -e KAFKA_LISTENERS=INTERNAL://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092 \
  123. -e KAFKA_ADVERTISED_LISTENERS=INTERNAL://127.0.0.1:9093,EXTERNAL://127.0.0.1:9092 \
  124. -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT \
  125. -e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL \
  126. -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  127. confluentinc/cp-kafka:5.1.2
  128. fi
  129. if [ "$NEED_SNUBA" = "true" ]; then
  130. sentry devservices up clickhouse snuba
  131. fi
  132. if [ "$NEED_CHARTCUTERIE" = "true" ]; then
  133. sentry devservices up --skip-only-if chartcuterie
  134. fi
  135. docker ps -a