action.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. name: 'Sentry Setup'
  2. description: 'Sets up a Sentry test environment'
  3. inputs:
  4. python:
  5. description: 'python version (2 or 3)'
  6. required: false
  7. default: '3'
  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. 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. PYTHON_VERSION: ${{ inputs.python }}
  36. NEED_KAFKA: ${{ inputs.kafka }}
  37. MATRIX_INSTANCE: ${{ matrix.instance }}
  38. MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }}
  39. run: |
  40. echo "PIP_DISABLE_PIP_VERSION_CHECK=on" >> $GITHUB_ENV
  41. echo "MIGRATIONS_TEST_MIGRATE=0" >> $GITHUB_ENV
  42. echo "SENTRY_LIGHT_BUILD=1" >> $GITHUB_ENV
  43. echo "SENTRY_SKIP_BACKEND_VALIDATION=1" >> $GITHUB_ENV
  44. [ "$PYTHON_VERSION" = "3" ] && echo "SENTRY_PYTHON3=1" >> $GITHUB_ENV || true
  45. ### node configuration ###
  46. echo "NODE_ENV=development" >> $GITHUB_ENV
  47. echo "NODE_OPTIONS=--max-old-space-size=4096" >> $GITHUB_ENV
  48. ### pytest-sentry configuration ###
  49. echo "PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079" >> $GITHUB_ENV
  50. echo "PYTEST_ADDOPTS=--reruns 5" >> $GITHUB_ENV
  51. # this handles pytest test sharding
  52. if [ "$MATRIX_INSTANCE" ]; then
  53. echo "TEST_GROUP=$MATRIX_INSTANCE" >> $GITHUB_ENV
  54. echo "TOTAL_TEST_GROUPS=$MATRIX_INSTANCE_TOTAL" >> $GITHUB_ENV
  55. fi
  56. # This records failures on master to sentry in order to detect flakey tests, as it's
  57. # expected that people have failing tests on their PRs
  58. [ "$GITHUB_REF" = "refs/heads/master" ] && echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV || true
  59. ### services configuration ###
  60. # Note: some backend tests (e.g. tests/sentry/eventstream/kafka/test_consumer.py) will behave
  61. # differently if these are set.
  62. if [ "$NEED_KAFKA" = "true" ]; then
  63. echo "SENTRY_KAFKA_HOSTS=127.0.0.1:9092" >> $GITHUB_ENV
  64. echo "SENTRY_ZOOKEEPER_HOSTS=127.0.0.1:2181" >> $GITHUB_ENV
  65. fi
  66. # Setup custom pytest matcher, see https://github.com/actions/setup-node/issues/97
  67. - name: Add pytest log matcher
  68. shell: bash
  69. run: |
  70. echo "::remove-matcher owner=pytest::"
  71. echo "::add-matcher::.github/pytest.json"
  72. - name: Install system dependencies
  73. shell: bash
  74. run: |
  75. sudo apt-get update
  76. sudo apt-get install -y --no-install-recommends \
  77. libxmlsec1-dev \
  78. libmaxminddb-dev
  79. - name: Set up outputs
  80. id: config
  81. env:
  82. MATRIX_INSTANCE: ${{ matrix.instance }}
  83. shell: bash
  84. run: |
  85. echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
  86. echo "::set-output name=matrix-instance-number::$(($MATRIX_INSTANCE+1))"
  87. echo "::set-output name=acceptance-dir::.artifacts/visual-snapshots/acceptance"
  88. - name: Install python dependencies
  89. shell: bash
  90. run: |
  91. python setup.py install_egg_info
  92. pip install wheel # GitHub Actions does not have `wheel` installed by default (unlike Travis)
  93. pip install -U -e ".[dev]"
  94. - name: Start devservices
  95. shell: bash
  96. env:
  97. NEED_KAFKA: ${{ inputs.kafka }}
  98. NEED_SNUBA: ${{ inputs.snuba }}
  99. run: |
  100. sentry init
  101. # redis, postgres are needed for almost every code path.
  102. sentry devservices up redis postgres
  103. # TODO: Use devservices kafka. See https://github.com/getsentry/sentry/pull/20986#issuecomment-704510570
  104. if [ "$NEED_KAFKA" = "true" ]; then
  105. docker run \
  106. --name sentry_zookeeper \
  107. -d --network host \
  108. -e ZOOKEEPER_CLIENT_PORT=2181 \
  109. confluentinc/cp-zookeeper:4.1.0
  110. docker run \
  111. --name sentry_kafka \
  112. -d --network host \
  113. -e KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
  114. -e KAFKA_LISTENERS=INTERNAL://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092 \
  115. -e KAFKA_ADVERTISED_LISTENERS=INTERNAL://127.0.0.1:9093,EXTERNAL://127.0.0.1:9092 \
  116. -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT \
  117. -e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL \
  118. -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  119. confluentinc/cp-kafka:5.1.2
  120. fi
  121. if [ "$NEED_SNUBA" = "true" ]; then
  122. sentry devservices up clickhouse snuba
  123. fi
  124. docker ps -a