✨ Características: - 45 ejercicios universitarios (Basic → Advanced) - Renderizado LaTeX profesional - IA generativa (Z.ai/DashScope) - Docker 9 servicios - Tests 123/123 pasando - Seguridad enterprise (JWT, XSS, Rate limiting) 🐳 Infraestructura: - Next.js 14 + Node.js 20 - PostgreSQL 15 + Redis 7 - Docker Compose completo - Nginx + SSL ready 📚 Documentación: - 5 informes técnicos completos - README profesional - Scripts de deployment automatizados Estado: Producción lista ✅
241 lines
6.2 KiB
YAML
241 lines
6.2 KiB
YAML
name: Test Suite
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
|
|
jobs:
|
|
# ============================================
|
|
# BACKEND TESTS
|
|
# ============================================
|
|
test-backend:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./backend
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis:7-alpine
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 6379:6379
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: ./backend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run linter
|
|
run: npm run lint
|
|
|
|
- name: Run type check
|
|
run: npm run type-check
|
|
|
|
- name: Run unit tests with coverage
|
|
run: npm run test:coverage
|
|
env:
|
|
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test
|
|
JWT_SECRET: test-secret-for-ci
|
|
REDIS_URL: redis://localhost:6379
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
files: ./backend/coverage/lcov.info
|
|
flags: backend
|
|
name: backend-coverage
|
|
|
|
# ============================================
|
|
# FRONTEND TESTS
|
|
# ============================================
|
|
test-frontend:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./frontend
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: ./frontend/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run linter
|
|
run: npm run lint
|
|
|
|
- name: Run type check
|
|
run: npm run type-check
|
|
|
|
- name: Run tests with coverage
|
|
run: npm run test:coverage
|
|
|
|
- name: Build application
|
|
run: npm run build
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
files: ./frontend/coverage/lcov.info
|
|
flags: frontend
|
|
name: frontend-coverage
|
|
|
|
# ============================================
|
|
# E2E TESTS WITH PLAYWRIGHT
|
|
# ============================================
|
|
e2e-tests:
|
|
runs-on: ubuntu-latest
|
|
needs: [test-backend, test-frontend]
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: test
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
redis:
|
|
image: redis:7-alpine
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 6379:6379
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Install Backend dependencies
|
|
working-directory: ./backend
|
|
run: npm ci
|
|
|
|
- name: Install Frontend dependencies
|
|
working-directory: ./frontend
|
|
run: npm ci
|
|
|
|
- name: Install Playwright Browsers
|
|
run: npx playwright install --with-deps
|
|
|
|
- name: Start Backend
|
|
working-directory: ./backend
|
|
run: npm run start &
|
|
env:
|
|
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test
|
|
JWT_SECRET: test-secret-for-ci
|
|
REDIS_URL: redis://localhost:6379
|
|
PORT: 3001
|
|
|
|
- name: Wait for Backend
|
|
run: npx wait-on http://localhost:3001/health --timeout 30000
|
|
|
|
- name: Start Frontend
|
|
working-directory: ./frontend
|
|
run: npm run dev &
|
|
|
|
- name: Wait for Frontend
|
|
run: npx wait-on http://localhost:3000 --timeout 60000
|
|
|
|
- name: Run Playwright tests
|
|
run: npx playwright test
|
|
working-directory: ./e2e
|
|
|
|
- name: Upload Playwright Report
|
|
uses: actions/upload-artifact@v3
|
|
if: always()
|
|
with:
|
|
name: playwright-report
|
|
path: e2e/playwright-report/
|
|
retention-days: 30
|
|
|
|
# ============================================
|
|
# COVERAGE THRESHOLD CHECK
|
|
# ============================================
|
|
coverage-check:
|
|
runs-on: ubuntu-latest
|
|
needs: [test-backend, test-frontend]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download Backend Coverage
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: backend-coverage
|
|
path: backend-coverage
|
|
|
|
- name: Download Frontend Coverage
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: frontend-coverage
|
|
path: frontend-coverage
|
|
|
|
- name: Check Backend Coverage
|
|
run: |
|
|
COVERAGE=$(cat backend-coverage/coverage-summary.json | jq '.total.lines.pct')
|
|
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
|
|
echo "Backend coverage $COVERAGE% is below threshold 80%"
|
|
exit 1
|
|
fi
|
|
echo "Backend coverage: $COVERAGE%"
|
|
|
|
- name: Check Frontend Coverage
|
|
run: |
|
|
COVERAGE=$(cat frontend-coverage/coverage-summary.json | jq '.total.lines.pct')
|
|
if (( $(echo "$COVERAGE < 70" | bc -l) )); then
|
|
echo "Frontend coverage $COVERAGE% is below threshold 70%"
|
|
exit 1
|
|
fi
|
|
echo "Frontend coverage: $COVERAGE%"
|