|
| 1 | +name: "Sentry self-hosted end-to-end tests" |
| 2 | +inputs: |
| 3 | + project_name: |
| 4 | + required: false |
| 5 | + description: "e.g. snuba, sentry, relay, self-hosted" |
| 6 | + image_url: |
| 7 | + required: false |
| 8 | + description: "The URL to the built relay, snuba, sentry image to test against." |
| 9 | + |
| 10 | +runs: |
| 11 | + using: "composite" |
| 12 | + steps: |
| 13 | + - name: Go into self-hosted directory |
| 14 | + shell: bash |
| 15 | + run: cd ${{ github.action_path }} |
| 16 | + |
| 17 | + - name: Configure to use the test image |
| 18 | + if: inputs.project_name && inputs.image_url |
| 19 | + shell: bash |
| 20 | + run: | |
| 21 | + image_var=$(echo ${{ inputs.project_name }}_IMAGE | tr '[:lower:]' '[:upper:]') |
| 22 | + echo "${image_var}=${{ inputs.image_url }}" >> $GITHUB_ENV |
| 23 | +
|
| 24 | + - name: Setup dev environment |
| 25 | + run: | |
| 26 | + pip install -r requirements-dev.txt |
| 27 | + echo "PY_COLORS=1" >> "$GITHUB_ENV" |
| 28 | + ### pytest-sentry configuration ### |
| 29 | + if [ "$GITHUB_REPOSITORY" = "getsentry/self-hosted" ]; then |
| 30 | + echo "PYTEST_SENTRY_DSN=$SELF_HOSTED_TESTING_DSN" >> $GITHUB_ENV |
| 31 | + echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV |
| 32 | +
|
| 33 | + # This records failures on master to sentry in order to detect flakey tests, as it's |
| 34 | + # expected that people have failing tests on their PRs |
| 35 | + if [ "$GITHUB_REF" = "refs/heads/master" ]; then |
| 36 | + echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV |
| 37 | + fi |
| 38 | + fi |
| 39 | +
|
| 40 | + - name: Get Compose |
| 41 | + env: |
| 42 | + COMPOSE_PATH: /usr/local/lib/docker/cli-plugins |
| 43 | + COMPOSE_VERSION: 'v2.26.0' |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + # Always remove `docker compose` support as that's the newer version |
| 47 | + # and comes installed by default nowadays. |
| 48 | + sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose" |
| 49 | + # Docker Compose v1 is installed here, remove it |
| 50 | + sudo rm -f "/usr/local/bin/docker-compose" |
| 51 | + sudo rm -f "${{ env.COMPOSE_PATH }}/docker-compose" |
| 52 | + sudo mkdir -p "${{ env.COMPOSE_PATH }}" |
| 53 | + sudo curl -L https://github.com/docker/compose/releases/download/${{ env.COMPOSE_VERSION }}/docker-compose-`uname -s`-`uname -m` -o "${{ env.COMPOSE_PATH }}/docker-compose" |
| 54 | + sudo chmod +x "${{ env.COMPOSE_PATH }}/docker-compose" |
| 55 | +
|
| 56 | + - name: Prepare Docker Volume Caching |
| 57 | + id: cache_key |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + # Set permissions for docker volumes so we can cache and restore |
| 61 | + sudo chmod o+x /var/lib/docker |
| 62 | + sudo chmod -R o+rwx /var/lib/docker/volumes |
| 63 | + source .env |
| 64 | + SENTRY_IMAGE_SHA=$(docker buildx imagetools inspect $SENTRY_IMAGE --format "{{println .Manifest.Digest}}") |
| 65 | + echo "SENTRY_IMAGE_SHA=$SENTRY_IMAGE_SHA" >> $GITHUB_OUTPUT |
| 66 | + SNUBA_IMAGE_SHA=$(docker buildx imagetools inspect $SNUBA_IMAGE --format "{{println .Manifest.Digest}}") |
| 67 | + echo "SNUBA_IMAGE_SHA=$SNUBA_IMAGE_SHA" >> $GITHUB_OUTPUT |
| 68 | +
|
| 69 | + - name: Restore DB Volumes Cache |
| 70 | + id: restore_cache |
| 71 | + uses: actions/cache/restore@v4 |
| 72 | + with: |
| 73 | + key: db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}-${{ steps.cache_key.outputs.SNUBA_IMAGE_SHA }} |
| 74 | + restore-keys: | |
| 75 | + db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }} |
| 76 | + db-volumes-v4- |
| 77 | + path: | |
| 78 | + /var/lib/docker/volumes/sentry-postgres/_data |
| 79 | + /var/lib/docker/volumes/sentry-clickhouse/_data |
| 80 | + /var/lib/docker/volumes/sentry-kafka/_data |
| 81 | +
|
| 82 | + - name: Install self-hosted |
| 83 | + env: |
| 84 | + SKIP_DB_MIGRATIONS: ${{ steps.restore_cache.outputs.cache-hit == 'true' && '1' || '' }} |
| 85 | + shell: bash |
| 86 | + run: | |
| 87 | + # This is for the cache restore on Kafka to work in older releases |
| 88 | + docker run --rm -v "sentry-kafka:/data" busybox chown -R 1000:1000 /data |
| 89 | + # Add some customizations to test that path |
| 90 | + cat <<EOT >> sentry/enhance-image.sh |
| 91 | + #!/bin/bash |
| 92 | + touch /created-by-enhance-image |
| 93 | + apt-get update |
| 94 | + apt-get install -y gcc libsasl2-dev python-dev-is-python3 libldap2-dev libssl-dev |
| 95 | + EOT |
| 96 | + chmod 755 sentry/enhance-image.sh |
| 97 | + echo "python-ldap" > sentry/requirements.txt |
| 98 | +
|
| 99 | + ./install.sh --no-report-self-hosted-issues --skip-commit-check |
| 100 | +
|
| 101 | + - name: Prepare Docker Volume Caching |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + # Set permissions for docker volumes so we can cache and restore |
| 105 | + # We need these for the backup/restore test snapshotting too |
| 106 | + sudo chmod o+x /var/lib/docker |
| 107 | + sudo chmod -R o+rx /var/lib/docker/volumes |
| 108 | + # Set tar ownership for it to be able to read |
| 109 | + # From: https://github.com/actions/toolkit/issues/946#issuecomment-1726311681 |
| 110 | + sudo chown root /usr/bin/tar && sudo chmod u+s /usr/bin/tar |
| 111 | + sudo chown root /usr/bin/rsync && sudo chmod u+s /usr/bin/rsync |
| 112 | +
|
| 113 | + - name: Save DB Volumes Cache |
| 114 | + if: steps.restore_cache.outputs.cache-hit != 'true' |
| 115 | + uses: actions/cache/save@v4 |
| 116 | + with: |
| 117 | + key: ${{ steps.restore_cache.outputs.cache-primary-key }} |
| 118 | + path: | |
| 119 | + /var/lib/docker/volumes/sentry-postgres/_data |
| 120 | + /var/lib/docker/volumes/sentry-clickhouse/_data |
| 121 | + /var/lib/docker/volumes/sentry-kafka/_data |
| 122 | +
|
| 123 | + - name: Integration Test |
| 124 | + shell: bash |
| 125 | + run: | |
| 126 | + rsync -aW --no-compress --mkpath \ |
| 127 | + /var/lib/docker/volumes/sentry-postgres \ |
| 128 | + /var/lib/docker/volumes/sentry-clickhouse \ |
| 129 | + /var/lib/docker/volumes/sentry-kafka \ |
| 130 | + "$RUNNER_TEMP/volumes/" |
| 131 | + docker compose up --wait |
| 132 | + pytest -x --cov --junitxml=junit.xml _integration-test/ |
| 133 | +
|
| 134 | + - name: Upload coverage to Codecov |
| 135 | + uses: codecov/codecov-action@v5 |
| 136 | + with: |
| 137 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 138 | + slug: getsentry/self-hosted |
| 139 | + |
| 140 | + - name: Upload test results to Codecov |
| 141 | + if: ${{ !cancelled() }} |
| 142 | + uses: codecov/test-results-action@v1 |
| 143 | + with: |
| 144 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments