diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 2dbae921..9f326acc 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -793,3 +793,113 @@ jobs: issue_number: context.issue.number, body: body }); + + # ============================================================================ + # E2E Tests (Playwright) for PR Builds + # ============================================================================ + # This job runs end-to-end tests using Playwright against the Docker image + # built for pull requests. It validates the application's functionality from + # the user's perspective before merging. + # + # Dependency Chain: build-and-push → e2e-tests-pr + # ============================================================================ + e2e-tests-pr: + name: E2E Tests (Playwright) + needs: build-and-push + runs-on: ubuntu-latest + timeout-minutes: 15 + if: | + github.event_name == 'pull_request' && + needs.build-and-push.outputs.skip_build != 'true' && + needs.build-and-push.result == 'success' + permissions: + contents: read + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 + + - name: Download Docker image artifact + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 + with: + name: pr-image-${{ github.event.pull_request.number }} + + - name: Load Docker image + run: | + echo "📦 Loading image from artifact..." + docker load -i charon-pr-image.tar + echo "✅ Image loaded successfully" + + - name: Normalize image name + run: | + IMAGE_NAME=$(echo "${{ github.repository_owner }}/charon" | tr '[:upper:]' '[:lower:]') + echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV + + - name: Verify loaded image + run: | + IMAGE_REF="ghcr.io/${{ env.IMAGE_NAME }}:pr-${{ github.event.pull_request.number }}" + if ! docker image inspect "${IMAGE_REF}" >/dev/null 2>&1; then + echo "❌ ERROR: Image not found: ${IMAGE_REF}" + docker images + exit 1 + fi + echo "✅ Image loaded: ${IMAGE_REF}" + + - name: Start application container + run: | + IMAGE_REF="ghcr.io/${{ env.IMAGE_NAME }}:pr-${{ github.event.pull_request.number }}" + docker run -d --name charon \ + -p 8080:8080 \ + -e CHARON_ENV=development \ + -e CHARON_DEBUG=1 \ + -e CHARON_ENCRYPTION_KEY=test-key-for-ci-only-not-production \ + "${IMAGE_REF}" + + - name: Wait for application health + run: | + echo "Waiting for application to be ready..." + timeout 120 bash -c 'until curl -sf http://localhost:8080/api/v1/health > /dev/null; do + echo "Waiting for health endpoint..." + sleep 2 + done' + echo "✅ Application is ready" + + - name: Setup Node.js + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6 + with: + node-version: lts/* + + - name: Install Playwright dependencies + run: | + npm ci + npx playwright install --with-deps chromium + + - name: Run Playwright E2E tests + env: + PLAYWRIGHT_BASE_URL: http://localhost:8080 + run: npx playwright test + + - name: Stop application container + if: always() + run: docker stop charon && docker rm charon + + - name: Upload Playwright report + if: always() + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: playwright-report-pr-${{ github.event.pull_request.number }} + path: playwright-report/ + retention-days: 7 + + - name: Create E2E Test Summary + if: always() + run: | + echo "## 🎭 E2E Test Results - PR #${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Image**: \`ghcr.io/${{ env.IMAGE_NAME }}:pr-${{ github.event.pull_request.number }}\`" >> $GITHUB_STEP_SUMMARY + echo "**Status**: ${{ job.status == 'success' && '✅ All tests passed' || '❌ Tests failed' }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + if [[ "${{ job.status }}" != "success" ]]; then + echo "📊 [View Test Report](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}#artifacts)" >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml.disabled similarity index 74% rename from .github/workflows/playwright.yml rename to .github/workflows/playwright.yml.disabled index c4de1ab2..02ce9cbf 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml.disabled @@ -1,4 +1,14 @@ -name: Playwright Tests +# ============================================================================ +# DISABLED: This workflow has been integrated into docker-build.yml +# ============================================================================ +# Integration date: January 12, 2026 +# Reason: Consolidated E2E testing with Docker build workflow for better +# visibility and to ensure tests run against the actual built image. +# +# See: .github/workflows/docker-build.yml → e2e-tests-pr job +# ============================================================================ + +name: Playwright Tests (DISABLED) on: push: branches: [ main, master ]