ci: Only test on compose 2.26 w/ customizations (#3506) #4722
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
# Run CI on all pushes to the master and release/** branches, and on all new | |
# pull requests, and on all pushes to pull requests (even if a pull request | |
# is not against master). | |
push: | |
branches: | |
- "master" | |
- "release/**" | |
pull_request: | |
schedule: | |
- cron: "0 0,12 * * *" | |
concurrency: | |
group: ${{ github.ref_name || github.sha }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
e2e-test: | |
if: github.repository_owner == 'getsentry' | |
runs-on: ubuntu-22.04 | |
name: "Sentry self-hosted end-to-end tests" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: self-hosted | |
- name: End to end tests | |
uses: getsentry/action-self-hosted-e2e-tests@main | |
with: | |
project_name: self-hosted | |
unit-test: | |
if: github.repository_owner == 'getsentry' | |
runs-on: ubuntu-22.04 | |
name: "unit tests" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Unit Tests | |
run: ./unit-test.sh | |
upgrade-test: | |
if: github.repository_owner == 'getsentry' | |
runs-on: ubuntu-22.04 | |
name: "Sentry upgrade test" | |
env: | |
REPORT_SELF_HOSTED_ISSUES: 0 | |
steps: | |
- name: Get latest self-hosted release version | |
run: | | |
LATEST_TAG=$(curl -s https://api.github.com/repos/getsentry/self-hosted/releases/latest | jq -r '.tag_name') | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | |
- name: Checkout latest release | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.LATEST_TAG }} | |
- name: Get Compose | |
run: | | |
# Docker Compose v1 is installed here, remove it | |
sudo rm -f "/usr/local/bin/docker-compose" | |
sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose" | |
sudo mkdir -p "/usr/local/lib/docker/cli-plugins" | |
sudo curl -L https://github.com/docker/compose/releases/download/v2.26.0/docker-compose-`uname -s`-`uname -m` -o "/usr/local/lib/docker/cli-plugins/docker-compose" | |
sudo chmod +x "/usr/local/lib/docker/cli-plugins/docker-compose" | |
- name: Prepare Docker Volume Caching | |
id: cache_key | |
run: | | |
# Set permissions for docker volumes so we can cache and restore | |
sudo chmod o+x /var/lib/docker | |
sudo chmod -R o+rwx /var/lib/docker/volumes | |
source .env | |
SENTRY_IMAGE_SHA=$(docker buildx imagetools inspect $SENTRY_IMAGE --format "{{println .Manifest.Digest}}") | |
echo "SENTRY_IMAGE_SHA=$SENTRY_IMAGE_SHA" >> $GITHUB_OUTPUT | |
SNUBA_IMAGE_SHA=$(docker buildx imagetools inspect $SNUBA_IMAGE --format "{{println .Manifest.Digest}}") | |
echo "SNUBA_IMAGE_SHA=$SNUBA_IMAGE_SHA" >> $GITHUB_OUTPUT | |
- name: Restore DB Volumes Cache | |
id: restore_cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}-${{ steps.cache_key.outputs.SNUBA_IMAGE_SHA }} | |
restore-keys: | | |
db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }} | |
db-volumes-v4- | |
path: | | |
/var/lib/docker/volumes/sentry-postgres/_data | |
/var/lib/docker/volumes/sentry-clickhouse/_data | |
/var/lib/docker/volumes/sentry-kafka/_data | |
- name: Install ${{ env.LATEST_TAG }} | |
env: | |
SKIP_DB_MIGRATIONS: ${{ steps.restore_cache.outputs.cache-hit == 'true' && '1' || '' }} | |
run: | | |
# This is for the cache restore on Kafka to work in older releases | |
docker run --rm -v "sentry-kafka:/data" busybox chown -R 1000:1000 /data | |
./install.sh | |
- name: Prepare Docker Volume Caching | |
run: | | |
# Set permissions for docker volumes so we can cache and restore | |
sudo chmod o+x /var/lib/docker | |
sudo chmod -R o+rx /var/lib/docker/volumes | |
# Set tar ownership for it to be able to read | |
# From: https://github.com/actions/toolkit/issues/946#issuecomment-1726311681 | |
sudo chown root /usr/bin/tar && sudo chmod u+s /usr/bin/tar | |
- name: Save DB Volumes Cache | |
if: steps.restore_cache.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
key: ${{ steps.restore_cache.outputs.cache-primary-key }} | |
path: | | |
/var/lib/docker/volumes/sentry-postgres/_data | |
/var/lib/docker/volumes/sentry-clickhouse/_data | |
/var/lib/docker/volumes/sentry-kafka/_data | |
- name: Checkout current ref | |
uses: actions/checkout@v4 | |
- name: Install current ref | |
run: | | |
# This is for the cache restore on Kafka to work in older releases | |
docker run --rm -v "sentry-kafka:/data" busybox chown -R 1000:1000 /data | |
./install.sh | |
- name: Inspect failure | |
if: failure() | |
run: | | |
docker compose ps | |
docker compose logs | |
integration-test: | |
if: github.repository_owner == 'getsentry' | |
runs-on: ubuntu-22.04 | |
name: integration test | |
env: | |
REPORT_SELF_HOSTED_ISSUES: 0 | |
SELF_HOSTED_TESTING_DSN: ${{ vars.SELF_HOSTED_TESTING_DSN }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup dev environment | |
run: | | |
pip install -r requirements-dev.txt | |
echo "PY_COLORS=1" >> "$GITHUB_ENV" | |
### pytest-sentry configuration ### | |
if [ "$GITHUB_REPOSITORY" = "getsentry/self-hosted" ]; then | |
echo "PYTEST_SENTRY_DSN=$SELF_HOSTED_TESTING_DSN" >> $GITHUB_ENV | |
echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV | |
# 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 | |
if [ "$GITHUB_REF" = "refs/heads/master" ]; then | |
echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV | |
fi | |
fi | |
- name: Get Compose | |
env: | |
COMPOSE_PATH: /usr/local/lib/docker/cli-plugins | |
COMPOSE_VERSION: 'v2.26.0' | |
run: | | |
# Always remove `docker compose` support as that's the newer version | |
# and comes installed by default nowadays. | |
sudo rm -f "/usr/local/lib/docker/cli-plugins/docker-compose" | |
# Docker Compose v1 is installed here, remove it | |
sudo rm -f "/usr/local/bin/docker-compose" | |
sudo rm -f "${{ env.COMPOSE_PATH }}/docker-compose" | |
sudo mkdir -p "${{ env.COMPOSE_PATH }}" | |
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" | |
sudo chmod +x "${{ env.COMPOSE_PATH }}/docker-compose" | |
- name: Prepare Docker Volume Caching | |
id: cache_key | |
run: | | |
# Set permissions for docker volumes so we can cache and restore | |
sudo chmod o+x /var/lib/docker | |
sudo chmod -R o+rwx /var/lib/docker/volumes | |
source .env | |
SENTRY_IMAGE_SHA=$(docker buildx imagetools inspect $SENTRY_IMAGE --format "{{println .Manifest.Digest}}") | |
echo "SENTRY_IMAGE_SHA=$SENTRY_IMAGE_SHA" >> $GITHUB_OUTPUT | |
SNUBA_IMAGE_SHA=$(docker buildx imagetools inspect $SNUBA_IMAGE --format "{{println .Manifest.Digest}}") | |
echo "SNUBA_IMAGE_SHA=$SNUBA_IMAGE_SHA" >> $GITHUB_OUTPUT | |
- name: Restore DB Volumes Cache | |
id: restore_cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }}-${{ steps.cache_key.outputs.SNUBA_IMAGE_SHA }} | |
restore-keys: | | |
db-volumes-v4-${{ steps.cache_key.outputs.SENTRY_IMAGE_SHA }} | |
db-volumes-v4- | |
path: | | |
/var/lib/docker/volumes/sentry-postgres/_data | |
/var/lib/docker/volumes/sentry-clickhouse/_data | |
/var/lib/docker/volumes/sentry-kafka/_data | |
- name: Install self-hosted | |
env: | |
SKIP_DB_MIGRATIONS: ${{ steps.restore_cache.outputs.cache-hit == 'true' && '1' || '' }} | |
run: | | |
# This is for the cache restore on Kafka to work in older releases | |
docker run --rm -v "sentry-kafka:/data" busybox chown -R 1000:1000 /data | |
./install.sh | |
- name: Prepare Docker Volume Caching | |
run: | | |
# Set permissions for docker volumes so we can cache and restore | |
sudo chmod o+x /var/lib/docker | |
sudo chmod -R o+rx /var/lib/docker/volumes | |
# Set tar ownership for it to be able to read | |
# From: https://github.com/actions/toolkit/issues/946#issuecomment-1726311681 | |
sudo chown root /usr/bin/tar && sudo chmod u+s /usr/bin/tar | |
- name: Save DB Volumes Cache | |
if: steps.restore_cache.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
key: ${{ steps.restore_cache.outputs.cache-primary-key }} | |
path: | | |
/var/lib/docker/volumes/sentry-postgres/_data | |
/var/lib/docker/volumes/sentry-clickhouse/_data | |
/var/lib/docker/volumes/sentry-kafka/_data | |
- name: Integration Test | |
run: | | |
docker compose up --wait | |
pytest --cov --junitxml=junit.xml _integration-test/ --customizations=enabled | |
- name: Inspect failure | |
if: failure() | |
run: | | |
docker compose ps | |
docker compose logs | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: getsentry/self-hosted | |
- name: Upload test results to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/test-results-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |