action.yml 4.8 KB

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