Issue #51: Enforce repository boundary at CI level using import-linter. Contract 'forbid_router_db_import' checks that app.routers never imports app.dependencies directly, keeping the DB access path through service contexts only. - Add import-linter>=2.0.0 to dev dependencies (backend/pyproject.toml) - Configure [tool.importlinter] with package_root and root_packages - Add [[tool.importlinter.contracts]] with type='forbidden', source app.routers, forbidden app.dependencies - Add 'Import Boundary' CI job (import-linter) - Document import-linter in CONTRIBUTING.md code quality table Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
101 lines
2.0 KiB
YAML
101 lines
2.0 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
backend:
|
|
name: Backend Tests
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -e ".[dev]"
|
|
|
|
- name: Run tests with coverage
|
|
run: pytest --cov=app --cov-report=term-missing --cov-fail-under=80
|
|
|
|
- name: Upload coverage report
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-report
|
|
path: backend/htmlcov/
|
|
retention-days: 7
|
|
|
|
ruff:
|
|
name: Lint
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: pip install ruff
|
|
|
|
- name: Run ruff
|
|
run: ruff check .
|
|
|
|
mypy:
|
|
name: Type Check
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: pip install -e ".[dev]"
|
|
|
|
- name: Run mypy
|
|
run: mypy app
|
|
|
|
import-linter:
|
|
name: Import Boundary
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: backend
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: pip install -e ".[dev]"
|
|
|
|
- name: Run import-linter
|
|
run: linter |