124 lines
3.3 KiB
YAML
124 lines
3.3 KiB
YAML
name: E2E Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ master, main ]
|
|
pull_request:
|
|
branches: [ master, main ]
|
|
|
|
jobs:
|
|
test-e2e:
|
|
timeout-minutes: 60
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:13
|
|
env:
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: readur_test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '18'
|
|
cache: 'npm'
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Setup Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
profile: minimal
|
|
override: true
|
|
|
|
- name: Install frontend dependencies
|
|
working-directory: ./frontend
|
|
run: npm ci
|
|
|
|
- name: Install Playwright Browsers
|
|
working-directory: ./frontend
|
|
run: npx playwright install --with-deps
|
|
|
|
- name: Build frontend
|
|
working-directory: ./frontend
|
|
run: npm run build
|
|
|
|
- name: Setup test database
|
|
run: |
|
|
PGPASSWORD=postgres psql -h localhost -U postgres -d readur_test -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
|
|
|
- name: Run database migrations
|
|
run: |
|
|
# Set environment variables for test database
|
|
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/readur_test"
|
|
export TEST_MODE=true
|
|
|
|
# Run migrations
|
|
cargo run --bin migrate
|
|
env:
|
|
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/readur_test
|
|
TEST_MODE: true
|
|
|
|
- name: Start backend server
|
|
run: |
|
|
# Build and start the backend in test mode
|
|
cargo build --release
|
|
|
|
# Start server in background
|
|
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/readur_test" \
|
|
TEST_MODE=true \
|
|
ROCKET_PORT=8000 \
|
|
./target/release/readur &
|
|
|
|
# Wait for server to be ready
|
|
timeout 60 bash -c 'until curl -f http://localhost:8000/health; do sleep 2; done'
|
|
env:
|
|
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/readur_test
|
|
TEST_MODE: true
|
|
ROCKET_PORT: 8000
|
|
|
|
- name: Start frontend dev server
|
|
working-directory: ./frontend
|
|
run: |
|
|
# Start Vite dev server in background
|
|
npm run dev &
|
|
|
|
# Wait for frontend to be ready
|
|
timeout 60 bash -c 'until curl -f http://localhost:5173; do sleep 2; done'
|
|
env:
|
|
VITE_API_BASE_URL: http://localhost:8000
|
|
|
|
- name: Run Playwright tests
|
|
working-directory: ./frontend
|
|
run: npm run test:e2e
|
|
env:
|
|
CI: true
|
|
|
|
- name: Upload test results
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: playwright-report
|
|
path: frontend/test-results/
|
|
retention-days: 30
|
|
|
|
- name: Upload test artifacts
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: playwright-artifacts
|
|
path: |
|
|
frontend/test-results/e2e-artifacts/
|
|
frontend/test-results/screenshots/
|
|
retention-days: 30 |