112 lines
3 KiB
YAML
112 lines
3 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
paths:
|
|
- 'backend/**'
|
|
- 'frontend/**'
|
|
- '.coveragerc'
|
|
- '.github/workflows/tests.yml'
|
|
pull_request:
|
|
branches: [master]
|
|
paths:
|
|
- 'backend/**'
|
|
- 'frontend/**'
|
|
- '.coveragerc'
|
|
- '.github/workflows/tests.yml'
|
|
|
|
jobs:
|
|
backend-tests:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
with:
|
|
enable-cache: true
|
|
cache-dependency-glob: 'backend/uv.lock'
|
|
|
|
- name: Install system dependencies (WeasyPrint)
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
libpango-1.0-0 \
|
|
libpangocairo-1.0-0 \
|
|
libgdk-pixbuf-2.0-0 \
|
|
libffi-dev \
|
|
shared-mime-info
|
|
|
|
- name: Install Python dependencies
|
|
working-directory: backend
|
|
run: uv sync --frozen
|
|
|
|
- name: Run tests with coverage
|
|
working-directory: backend
|
|
env:
|
|
DJANGO_SETTINGS_MODULE: crm.test_settings
|
|
SECRET_KEY: test-secret-key-for-ci
|
|
ADMIN_EMAIL: admin@test.com
|
|
run: uv run pytest -m "not postgres_only" --tb=short -v
|
|
|
|
- name: Generate coverage badge
|
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
working-directory: backend
|
|
run: uvx --from "genbadge[coverage]" genbadge coverage -i coverage.xml -o ../coverage-badge.svg
|
|
|
|
- name: Commit coverage badge
|
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
run: |
|
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
|
git config --local user.name "github-actions[bot]"
|
|
git add coverage-badge.svg || true
|
|
git diff --staged --quiet || git commit -m "Update coverage badge [skip ci]"
|
|
git push || true
|
|
|
|
- name: Upload coverage report
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-report
|
|
path: backend/htmlcov/
|
|
retention-days: 14
|
|
|
|
frontend-checks:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10
|
|
|
|
- name: Install dependencies
|
|
working-directory: frontend
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Prettier format check
|
|
working-directory: frontend
|
|
run: pnpm prettier --check . || echo "::warning::Prettier found formatting issues in $(pnpm prettier --check . 2>&1 | grep -c '^\[warn\]') files. Run 'pnpm format' to fix."
|
|
|
|
- name: ESLint
|
|
working-directory: frontend
|
|
run: pnpm eslint .
|
|
|
|
- name: Type check (svelte-check)
|
|
working-directory: frontend
|
|
run: pnpm check
|
|
|
|
- name: Build
|
|
working-directory: frontend
|
|
run: pnpm build
|