Skip to content

chore(devcontainer): consolidate and simplify dev/test/ci envs #1244

chore(devcontainer): consolidate and simplify dev/test/ci envs

chore(devcontainer): consolidate and simplify dev/test/ci envs #1244

Workflow file for this run

name: e2e tests
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
permissions:
contents: read
packages: read
concurrency:
group: e2e-tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
e2e-tests:
name: e2e tests (ruby ${{ matrix.ruby.flavor }}, ${{ matrix.adapter }})
runs-on: ubuntu-latest
timeout-minutes: 8
strategy:
fail-fast: false
matrix:
ruby:
- version: "3.4.9"
flavor: "3.4"
- version: "4.0.3"
flavor: "4.0"
adapter:
- async
- inline
- sidekiq
- resque
- delayed_job
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Read devcontainer version
id: devcontainer-version
run: echo "version=$(cat .devcontainer/VERSION)" >> $GITHUB_OUTPUT
- name: Set up `.env` file
run: |
cd .devcontainer
cp .env.example .env
echo "SENTRY_E2E_ACTIVE_JOB_ADAPTER=${{ matrix.adapter }}" >> .env
echo "REDIS_URL=redis://redis:6379" >> .env
- name: Log in to GHCR
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull test container image
run: docker pull ghcr.io/getsentry/sentry-ruby-devcontainer-${{ matrix.ruby.flavor }}:${{ steps.devcontainer-version.outputs.version }}
- name: Prepare docker resources
run: |
network="sentry-ruby-e2e-${{ github.run_id }}-${{ matrix.ruby.flavor }}-${{ matrix.adapter }}"
bundle_volume="sentry-ruby-e2e-bundle-${{ github.run_id }}-${{ matrix.ruby.flavor }}-${{ matrix.adapter }}"
redis_container="sentry-ruby-e2e-redis-${{ github.run_id }}-${{ matrix.ruby.flavor }}-${{ matrix.adapter }}"
test_container="sentry-ruby-e2e-test-${{ github.run_id }}-${{ matrix.ruby.flavor }}-${{ matrix.adapter }}"
echo "E2E_NETWORK=${network}" >> "$GITHUB_ENV"
echo "E2E_BUNDLE_VOLUME=${bundle_volume}" >> "$GITHUB_ENV"
echo "E2E_REDIS_CONTAINER=${redis_container}" >> "$GITHUB_ENV"
echo "E2E_TEST_CONTAINER=${test_container}" >> "$GITHUB_ENV"
docker network create "${network}"
docker volume create "${bundle_volume}"
docker run -d \
--name "${redis_container}" \
--network "${network}" \
redis:latest
for _ in $(seq 1 30); do
if docker exec "${redis_container}" redis-cli ping | grep -q PONG; then
exit 0
fi
sleep 1
done
echo "Redis failed to become ready" >&2
exit 1
- name: Restore node_modules cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: spec/apps/svelte-mini/node_modules
key: ${{ runner.os }}-${{ runner.arch }}-node-modules-${{ hashFiles('spec/apps/svelte-mini/package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-node-modules-
- name: Set up test container
run: |
docker run --rm \
--network "${E2E_NETWORK}" \
--env-file .devcontainer/.env \
--env BUNDLE_PATH=/home/sentry/bundle \
--volume "${PWD}:/workspaces/sentry-ruby" \
--volume "${E2E_BUNDLE_VOLUME}:/home/sentry/bundle" \
"ghcr.io/getsentry/sentry-ruby-devcontainer-${{ matrix.ruby.flavor }}:${{ steps.devcontainer-version.outputs.version }}" \
.devcontainer/run .devcontainer/setup --only .,spec/apps/rails-mini
- name: Start test services
run: |
docker run -d \
--name "${E2E_TEST_CONTAINER}" \
--network "${E2E_NETWORK}" \
--publish 4000:4000 \
--publish 4001:4001 \
--env-file .devcontainer/.env \
--env BUNDLE_PATH=/home/sentry/bundle \
--volume "${PWD}:/workspaces/sentry-ruby" \
--volume "${E2E_BUNDLE_VOLUME}:/home/sentry/bundle" \
"ghcr.io/getsentry/sentry-ruby-devcontainer-${{ matrix.ruby.flavor }}:${{ steps.devcontainer-version.outputs.version }}" \
.devcontainer/run mise run e2e:serve
- name: "Wait for rails-mini app to be ready"
uses: nev7n/wait_for_response@8bfc0523300e46e24e1b42d6783680aa921ee6cc # v1.2.0
with:
url: 'http://localhost:4000/health'
responseCode: 200
timeout: 90000
interval: 500
- name: "Wait for svelte-mini app to be ready"
uses: nev7n/wait_for_response@8bfc0523300e46e24e1b42d6783680aa921ee6cc # v1.2.0
with:
url: 'http://localhost:4001/health'
responseCode: 200
timeout: 90000
interval: 500
- name: Run e2e tests via sentry-test
run: |
docker exec "${E2E_TEST_CONTAINER}" bundle exec rake
- name: Stop e2e services
if: always()
run: |
docker rm -f "${E2E_TEST_CONTAINER}" "${E2E_REDIS_CONTAINER}" 2>/dev/null || true
docker network rm "${E2E_NETWORK}" 2>/dev/null || true
docker volume rm "${E2E_BUNDLE_VOLUME}" 2>/dev/null || true
- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-test-logs-ruby-${{ matrix.ruby.version }}-${{ matrix.adapter }}
path: |
log/sentry_debug_events.log
retention-days: 7