Initial commit: AI project template #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main, develop] | |
pull_request: | |
branches: [main, develop] | |
jobs: | |
backend-test: | |
name: Backend Tests | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:16-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: testdb | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Install dependencies | |
working-directory: ./backend | |
run: uv sync --frozen | |
- name: Run linting | |
working-directory: ./backend | |
run: uv run ruff check . | |
- name: Run type checking | |
working-directory: ./backend | |
run: uv run mypy . | |
- name: Run tests | |
working-directory: ./backend | |
env: | |
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb | |
run: uv run pytest --cov=apps --cov-report=xml | |
- name: Upload coverage | |
uses: codecov/codecov-action@v4 | |
with: | |
file: ./backend/coverage.xml | |
flags: backend | |
frontend-test: | |
name: Frontend Tests | |
runs-on: ubuntu-latest | |
steps: | |
- 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 | |
working-directory: ./frontend | |
run: npm ci | |
- name: Run linting | |
working-directory: ./frontend | |
run: npm run lint | |
- name: Run type checking | |
working-directory: ./frontend | |
run: npm run type-check | |
- name: Build application | |
working-directory: ./frontend | |
run: npm run build | |
- name: Run E2E tests | |
working-directory: ./frontend | |
run: npx playwright install --with-deps && npm run test:e2e | |
docker-build: | |
name: Docker Build Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build Backend Docker image | |
run: docker build -t project-backend ./backend | |
- name: Build Frontend Docker image | |
run: docker build -t project-frontend ./frontend | |
- name: Test Docker Compose | |
run: | | |
docker-compose up -d | |
sleep 30 | |
curl -f http://localhost:8000/api/docs || exit 1 | |
curl -f http://localhost:3000 || exit 1 | |
docker-compose down |