.PHONY: setup test test-postgres lint migrations-check check

# Fleet-Standard-Einstieg (pkg-agents-v1, platform #2075 K2): make setup && make test
# Bis 2026-09-16 hatte der Kern kein Makefile (#29) — Tests liefen mit rohem pytest.
PY := .venv/bin/python

setup:
	python3 -m venv .venv
	.venv/bin/pip install -U pip
	.venv/bin/pip install -e ".[dev]" 'psycopg[binary]'

# Schnell, gegen SQLite (tests/settings.py waehlt SQLite, solange POSTGRES_HOST fehlt).
# Ohne weiteres -q: pyproject.toml setzt es schon (addopts), ein zweites
# unterdrueckt die Ergebniszeile "N passed".
test:
	$(PY) -m pytest

# Wie die CI, gegen Postgres 16 in einem Wegwerf-Container. Die RLS-Tests wirken
# nur hier — unter SQLite werden sie uebersprungen.
test-postgres:
	PY=$(PY) scripts/test_postgres.sh

lint:
	$(PY) -m ruff check .
	$(PY) -m ruff format --check .

migrations-check:
	$(PY) -m django makemigrations --check --settings=tests.settings

# Dieselben Schritte wie .github/workflows/ci.yml
check: lint test-postgres migrations-check
