Skip to content

feat: add end-to-end testing setup with Playwright #14

feat: add end-to-end testing setup with Playwright

feat: add end-to-end testing setup with Playwright #14

Workflow file for this run

name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
matrix:
database: [postgres, mongo, sqlite]
steps:
# prepare environment and dependencies
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
# prepare services
- name: Create .env file
run: cp .env.prod.example .env
- name: Start services
run: docker compose -f docker-compose.prod.${{ matrix.database }}.yml up -d
- name: Show container logs
run: |
echo "=== Container Status ==="
docker compose -f docker-compose.prod.${{ matrix.database }}.yml ps
echo "=== Container Logs ==="
docker compose -f docker-compose.prod.${{ matrix.database }}.yml logs
- name: Wait for services to be ready
run: |
echo "Waiting for services to be healthy..."
timeout 60 bash -c '
attempt=1
until curl -f http://localhost:8383/api/v1/health; do
echo "Attempt $attempt: Health check failed, retrying in 1 second..."
response=$(curl -s http://localhost:8383/api/v1/health || echo "connection failed")
status_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8383/api/v1/health || echo "000")
echo " Status Code: $status_code"
echo " Response Body: $response"
attempt=$((attempt + 1))
sleep 5
echo "=== Container Status ==="
docker compose -f docker-compose.prod.${{ matrix.database }}.yml ps
echo "=== Server Logs ==="
docker compose -f docker-compose.prod.${{ matrix.database }}.yml logs server
echo "=== Gateway Logs ==="
docker compose -f docker-compose.prod.${{ matrix.database }}.yml logs gateway
done
' || echo "Health check timed out after 60 seconds"
echo "Health check succeeded! Waiting additional 5 seconds for stability..."
sleep 5
- name: Run Playwright tests
run: pnpm exec playwright test
- name: Stop services
if: always()
run: docker compose -f docker-compose.prod.${{ matrix.database }}.yml down
# epilogue
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report-${{ matrix.database }}
path: playwright-report/
retention-days: 30