Improved devcontainer setup with e2e test mini infra #29
Workflow file for this run
This file contains hidden or 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: e2e tests | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| concurrency: | |
| group: e2e-tests-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| e2e-tests: | |
| name: e2e tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby_version: ["3.4.5"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ runner.temp }}/.buildx-cache | |
| key: ${{ runner.os }}-test-buildx-${{ github.sha }} | |
| restore-keys: ${{ runner.os }}-test-buildx- | |
| - name: Set up `.env` file | |
| run: | | |
| cd .devcontainer | |
| cp .env.example .env | |
| - name: Build rails mini image | |
| uses: docker/build-push-action@v2 | |
| with: | |
| builder: ${{ steps.buildx.outputs.name }} | |
| context: .devcontainer | |
| file: .devcontainer/Dockerfile | |
| target: rails-mini | |
| tags: sentry-ruby/rails-mini:latest | |
| build-args: | | |
| IMAGE=ruby | |
| VERSION=${{ matrix.ruby_version }} | |
| push: false | |
| load: true | |
| cache-from: type=local,src=${{ runner.temp }}/.buildx-cache | |
| cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max | |
| - name: Build svelte mini image | |
| uses: docker/build-push-action@v2 | |
| with: | |
| builder: ${{ steps.buildx.outputs.name }} | |
| context: .devcontainer | |
| file: .devcontainer/Dockerfile | |
| target: svelte-mini | |
| tags: sentry-ruby/svelte-mini:latest | |
| build-args: | | |
| IMAGE=ruby | |
| VERSION=${{ matrix.ruby_version }} | |
| push: false | |
| load: true | |
| cache-from: type=local,src=${{ runner.temp }}/.buildx-cache | |
| cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max | |
| - name: Build sentry-test image | |
| uses: docker/build-push-action@v2 | |
| with: | |
| builder: ${{ steps.buildx.outputs.name }} | |
| context: .devcontainer | |
| file: .devcontainer/Dockerfile | |
| target: test | |
| tags: sentry-ruby/sentry-test:latest | |
| build-args: | | |
| IMAGE=ruby | |
| VERSION=${{ matrix.ruby_version }} | |
| push: false | |
| load: true | |
| cache-from: type=local,src=${{ runner.temp }}/.buildx-cache | |
| cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max | |
| - name: Start mini rails app | |
| run: | | |
| cd .devcontainer | |
| source .env | |
| docker compose --profile e2e up -d sentry-rails-mini | |
| - name: Start mini svelte app | |
| run: | | |
| cd .devcontainer | |
| source .env | |
| docker compose --profile e2e up -d sentry-svelte-mini | |
| - name: Wait for services to be fully ready | |
| run: | | |
| cd .devcontainer | |
| source .env | |
| echo "⏳ Waiting for services to be fully ready..." | |
| # Wait for Rails app to respond with 200 | |
| timeout 90 bash -c 'until docker compose --profile e2e run --rm sentry-test curl -s -o /dev/null -w "%{http_code}" http://sentry-rails-mini:4000/health | grep -q "200"; do echo "Waiting for Rails app..."; sleep 2; done' || (echo "❌ Rails app failed to become ready" && exit 1) | |
| echo "✅ Rails app is ready" | |
| # Wait for Svelte app to respond with 200 | |
| timeout 90 bash -c 'until docker compose --profile e2e run --rm sentry-test curl -s -o /dev/null -w "%{http_code}" http://sentry-svelte-mini:4001/health | grep -q "200"; do echo "Waiting for Svelte app..."; sleep 2; done' || (echo "❌ Svelte app failed to become ready" && exit 1) | |
| echo "✅ Svelte app is ready" | |
| - name: Run e2e tests | |
| run: | | |
| cd .devcontainer | |
| source .env | |
| docker compose --profile e2e run --rm sentry-test bundle exec rake | |
| - name: Stop e2e services | |
| if: always() | |
| run: | | |
| cd .devcontainer | |
| source .env | |
| docker compose --profile e2e down | |
| - name: Upload test artifacts | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: e2e-test-logs-ruby-${{ matrix.ruby_version }} | |
| path: | | |
| log/sentry_debug_events.log | |
| retention-days: 7 | |
| - # Temp fix | |
| # https://github.com/docker/build-push-action/issues/252 | |
| # https://github.com/moby/buildkit/issues/1896 | |
| name: Move cache | |
| run: | | |
| rm -rf ${{ runner.temp }}/.buildx-cache | |
| mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache |