173 lines
4.5 KiB
YAML
173 lines
4.5 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop, feature/* ]
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
|
|
jobs:
|
|
backend-tests:
|
|
name: Backend Tests (Python)
|
|
runs-on: my-runner
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
env:
|
|
POSTGRES_PASSWORD: test_password
|
|
POSTGRES_USER: test_user
|
|
POSTGRES_DB: test_db
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.13
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.13'
|
|
|
|
- name: Install uv
|
|
run: |
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
- name: Install backend dependencies
|
|
run: |
|
|
cd backend
|
|
uv venv
|
|
source .venv/bin/activate
|
|
uv sync --dev
|
|
|
|
- name: Run backend linting (ruff)
|
|
run: |
|
|
cd backend
|
|
source .venv/bin/activate
|
|
ruff check .
|
|
ruff format --check .
|
|
|
|
- name: Run backend type checking (pyright)
|
|
run: |
|
|
cd backend
|
|
source .venv/bin/activate
|
|
pyright
|
|
|
|
- name: Run backend docstring linting (darglint)
|
|
run: |
|
|
cd backend
|
|
source .venv/bin/activate
|
|
darglint --config ../.darglint **/*.py
|
|
|
|
- name: Run backend tests with coverage and automatic typeguard
|
|
run: |
|
|
cd backend
|
|
source .venv/bin/activate
|
|
# Typeguard runs automatically via pytest plugin, no code changes needed
|
|
pytest --cov=. --cov-report=xml --cov-report=html --cov-report=term-missing -v \
|
|
--typeguard-packages=app,src
|
|
env:
|
|
DATABASE_URL: postgresql://test_user:test_password@localhost:5432/test_db
|
|
|
|
- name: Upload backend coverage to artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: backend-coverage
|
|
path: backend/htmlcov/
|
|
|
|
frontend-tests:
|
|
name: Frontend Tests (TypeScript/Vue)
|
|
runs-on: my-runner
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Install frontend dependencies
|
|
run: |
|
|
cd frontend
|
|
npm ci
|
|
|
|
- name: Run frontend linting (ESLint)
|
|
run: |
|
|
cd frontend
|
|
npm run lint
|
|
|
|
- name: Run frontend formatting check (Prettier)
|
|
run: |
|
|
cd frontend
|
|
npm run format:check
|
|
|
|
- name: Run frontend type checking (vue-tsc)
|
|
run: |
|
|
cd frontend
|
|
npm run type-check
|
|
|
|
- name: Run frontend tests with coverage and automatic Zod validation
|
|
run: |
|
|
cd frontend
|
|
# Zod validation happens automatically in test mode, no explicit .parse() calls needed
|
|
npm run test:coverage
|
|
|
|
- name: Upload frontend coverage to artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: frontend-coverage
|
|
path: frontend/coverage/
|
|
|
|
integration-tests:
|
|
name: Integration Tests
|
|
runs-on: my-runner
|
|
needs: [backend-tests, frontend-tests]
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
env:
|
|
POSTGRES_PASSWORD: test_password
|
|
POSTGRES_USER: test_user
|
|
POSTGRES_DB: test_db
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432:5432
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and test with Docker Compose
|
|
run: |
|
|
docker compose -f compose.yml -f compose.dev.yml build
|
|
docker compose -f compose.yml -f compose.dev.yml up -d
|
|
sleep 30 # Wait for services to be ready
|
|
|
|
# Run integration tests
|
|
docker compose -f compose.yml -f compose.dev.yml exec -T backend pytest tests/integration/
|
|
docker compose -f compose.yml -f compose.dev.yml exec -T frontend npm run test:e2e
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: |
|
|
docker compose -f compose.yml -f compose.dev.yml down -v
|