123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- name: 'Sentry Setup'
- description: 'Sets up a Sentry test environment'
- inputs:
- snuba:
- description: 'Is snuba required?'
- required: false
- default: 'false'
- kafka:
- description: 'Is kafka required?'
- required: false
- default: 'false'
- chartcuterie:
- description: 'Is chartcuterie required?'
- required: false
- default: 'false'
- outputs:
- yarn-cache-dir:
- description: "Path to yarn cache"
- value: ${{ steps.config.outputs.yarn-cache-dir }}
- pip-cache-dir:
- description: "Path to pip cache"
- value: ${{ steps.pip-cache.outputs.pip-cache }}
- acceptance-dir:
- description: "Path to acceptance visual snapshot artifacts"
- value: ${{ steps.config.outputs.acceptance-dir }}
- matrix-instance-number:
- description: "The matrix instance number (starting at 1)"
- value: ${{ steps.config.outputs.matrix-instance-number }}
- runs:
- using: "composite"
- steps:
- - name: Setup default environment variables
- shell: bash
- env:
- NEED_KAFKA: ${{ inputs.kafka }}
- MATRIX_INSTANCE: ${{ matrix.instance }}
- MATRIX_INSTANCE_TOTAL: ${{ strategy.job-total }}
- run: |
- echo "PIP_DISABLE_PIP_VERSION_CHECK=on" >> $GITHUB_ENV
- echo "MIGRATIONS_TEST_MIGRATE=0" >> $GITHUB_ENV
- echo "SENTRY_LIGHT_BUILD=1" >> $GITHUB_ENV
- echo "SENTRY_SKIP_BACKEND_VALIDATION=1" >> $GITHUB_ENV
- ### node configuration ###
- echo "NODE_ENV=development" >> $GITHUB_ENV
- echo "NODE_OPTIONS=--max-old-space-size=4096" >> $GITHUB_ENV
- ### pytest-sentry configuration ###
- echo "PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079" >> $GITHUB_ENV
- echo "PYTEST_ADDOPTS=--reruns 5" >> $GITHUB_ENV
- # this handles pytest test sharding
- if [ "$MATRIX_INSTANCE" ]; then
- echo "TEST_GROUP=$MATRIX_INSTANCE" >> $GITHUB_ENV
- echo "TOTAL_TEST_GROUPS=$MATRIX_INSTANCE_TOTAL" >> $GITHUB_ENV
- fi
- # This records failures on master to sentry in order to detect flakey tests, as it's
- # expected that people have failing tests on their PRs
- [ "$GITHUB_REF" = "refs/heads/master" ] && echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV || true
- ### services configuration ###
- echo "BIGTABLE_EMULATOR_HOST=localhost:8086" >> $GITHUB_ENV
- # Note: some backend tests (e.g. tests/sentry/eventstream/kafka/test_consumer.py) will behave
- # differently if these are set.
- if [ "$NEED_KAFKA" = "true" ]; then
- echo "SENTRY_KAFKA_HOSTS=127.0.0.1:9092" >> $GITHUB_ENV
- echo "SENTRY_ZOOKEEPER_HOSTS=127.0.0.1:2181" >> $GITHUB_ENV
- fi
- - name: Install system dependencies
- shell: bash
- run: |
- sudo apt-get update
- sudo apt-get install -y --no-install-recommends \
- libxmlsec1-dev \
- libmaxminddb-dev
- - name: Set up outputs
- id: config
- env:
- MATRIX_INSTANCE: ${{ matrix.instance }}
- shell: bash
- run: |
- echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
- echo "::set-output name=matrix-instance-number::$(($MATRIX_INSTANCE+1))"
- echo "::set-output name=acceptance-dir::.artifacts/visual-snapshots/acceptance"
- - name: Install python dependencies
- shell: bash
- run: |
- python setup.py install_egg_info
- pip install wheel # GitHub Actions does not have `wheel` installed by default
- pip install -U -e ".[dev]"
- # pytest plugin used for better pytest failure annotations
- pip install pytest-github-actions-annotate-failures
- - name: Start devservices
- shell: bash
- env:
- NEED_KAFKA: ${{ inputs.kafka }}
- NEED_SNUBA: ${{ inputs.snuba }}
- NEED_CHARTCUTERIE: ${{ inputs.chartcuterie }}
- run: |
- sentry init
- # redis, postgres are needed for almost every code path.
- sentry devservices up redis postgres
- if [ "$BIGTABLE_EMULATOR_HOST" ]; then
- sentry devservices up --skip-only-if bigtable
- fi
- # TODO: Use devservices kafka. See https://github.com/getsentry/sentry/pull/20986#issuecomment-704510570
- if [ "$NEED_KAFKA" = "true" ]; then
- docker run \
- --name sentry_zookeeper \
- -d --network host \
- -e ZOOKEEPER_CLIENT_PORT=2181 \
- confluentinc/cp-zookeeper:4.1.0
- docker run \
- --name sentry_kafka \
- -d --network host \
- -e KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181 \
- -e KAFKA_LISTENERS=INTERNAL://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092 \
- -e KAFKA_ADVERTISED_LISTENERS=INTERNAL://127.0.0.1:9093,EXTERNAL://127.0.0.1:9092 \
- -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT \
- -e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL \
- -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
- confluentinc/cp-kafka:5.1.2
- fi
- if [ "$NEED_SNUBA" = "true" ]; then
- sentry devservices up clickhouse snuba
- fi
- if [ "$NEED_CHARTCUTERIE" = "true" ]; then
- sentry devservices up --skip-only-if chartcuterie
- fi
- docker ps -a
|