action.yml 5.1 KB

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