diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8a54113 --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +# Команды разработки arm-core. Backend — api/.venv; запуск из корня репозитория. +VENV := api/.venv +BIN := $(CURDIR)/$(VENV)/bin +COMPOSE_FILE ?= ../docs/dev/docker-compose.yml + +.PHONY: venv lint test test-integration check check-full up migrate seed seed-dev + +# Python 3.11 (версия платформы); внутренние пакеты raisa_* вне банка недоступны — пропускаем их +venv: + cd api && uv venv --python 3.11 .venv + cd api && grep -v '^raisa_' requirements.txt | uv pip install --python .venv/bin/python -r - + cd api && grep -v '^-r' requirements-dev.txt | uv pip install --python .venv/bin/python -r - + +lint: + cd api && $(BIN)/ruff check . + cd api && $(BIN)/ruff format --check . + cd api && $(BIN)/mypy src + +test: + cd api && $(BIN)/pytest -m "not integration" + +test-integration: + cd api && $(BIN)/pytest -m integration + +check: lint test + +# TODO (задача 25): добавить фронт (lint/test/build web/), проверку миграций с нуля и откат, актуальность OpenAPI +check-full: check test-integration + +up: + docker compose -f $(COMPOSE_FILE) up -d + +migrate: + cd api && $(BIN)/alembic upgrade head + +seed: + cd api && $(BIN)/python -m scripts.seed + +seed-dev: + cd api && $(BIN)/python -m scripts.seed --dev diff --git a/api/pyproject.toml b/api/pyproject.toml new file mode 100644 index 0000000..45bc777 --- /dev/null +++ b/api/pyproject.toml @@ -0,0 +1,28 @@ +# Настройки инструментов качества. Зависимости — в requirements*.txt, pytest — в pytest.ini. + +[tool.ruff] +line-length = 120 +target-version = "py311" + +[tool.ruff.lint] +select = ["E", "F", "I", "UP", "B", "PL"] + +[tool.ruff.lint.isort] +known-first-party = ["src", "scripts"] + +[tool.mypy] +python_version = "3.11" +strict = false +check_untyped_defs = true +plugins = ["pydantic.mypy"] +mypy_path = "." +explicit_package_bases = true + +[[tool.mypy.overrides]] +module = ["src.models.*", "src.domain.*"] +strict = true + +# Сторонние пакеты без типов (или недоступные вне банка) +[[tool.mypy.overrides]] +module = ["smbclient.*", "nkeys.*", "miniopy_async.*", "nats.*", "raisa_*", "pydbml.*"] +ignore_missing_imports = true diff --git a/api/pytest.ini b/api/pytest.ini index 2dc434a..7ae5279 100644 --- a/api/pytest.ini +++ b/api/pytest.ini @@ -19,3 +19,6 @@ env = APP_ENV=test ENV_FILE=.env.test norecursedirs = .git __pycache__ .venv env build dist +markers = + integration: тесты, которым нужны PostgreSQL/NATS (docker compose); запускаются отдельно от юнит-тестов + fixtures: тесты на реальных данных из ../fixtures (внутренний доступ) diff --git a/api/requirements-dev.txt b/api/requirements-dev.txt index e4d6841..4b595ce 100644 --- a/api/requirements-dev.txt +++ b/api/requirements-dev.txt @@ -1,50 +1,12 @@ -aiosqlite -alembic -annotated-types==0.7.0 -anyio==4.8.0 -argon2-cffi -asyncpg -certifi==2024.12.14 -click==8.1.8 -colorama==0.4.6 -dnspython==2.7.0 -email_validator==2.2.0 -et_xmlfile==2.0.0 -fastapi==0.115.7 -fastapi-cli==0.0.7 -h11==0.14.0 -httpcore==1.0.7 -httptools==0.6.4 -httpx==0.27.2 -idna==3.10 -itsdangerous==2.2.0 -Jinja2==3.1.5 -markdown-it-py==3.0.0 -MarkupSafe==3.0.2 -mdurl==0.1.2 -openpyxl==3.1.5 -orjson==3.10.15 -pydantic==2.10.6 -pydantic-extra-types==2.10.2 -pydantic-settings==2.7.1 -pydantic_core==2.27.2 -Pygments==2.19.1 -python-dotenv==1.0.1 -python-jose -python-multipart==0.0.20 -PyYAML==6.0.2 -rich==13.9.4 -rich-toolkit==0.13.2 -shellingham==1.5.4 -sniffio==1.3.1 -sqlalchemy -starlette==0.45.3 -typer==0.15.1 -typing_extensions==4.12.2 -ujson==5.10.0 -uvicorn==0.34.0 -watchfiles==1.0.4 -websockets==14.2 -pytest-asyncio -pytest-env -cosmic-ray \ No newline at end of file +# Инструменты разработки и проверок. Платформенные зависимости — в requirements.txt (не меняем). +# Нижние границы мажорных версий: воспроизводимо, но без конфликта с пинами платформы. +-r requirements.txt +ruff>=0.8 +mypy>=1.13 +pytest>=8.3 +pytest-asyncio>=0.24 +pytest-env>=1.1 +pytest-cov>=6.0 +PyJWT[crypto]>=2.9 +pydbml>=1.1 +types-PyYAML>=6.0