Files
siftlode/backend/docker-compose.test.yml
T
peter 751e1ae5ed test: a size and complexity ratchet; coverage reported on both sides
The "class size" item from the quality checklist, measured:
- A shipped file over 800 lines may not grow past its line count today
  (13 frontend, 11 backend). No other file may cross 800.
- A function over the complexity limit may not rise, and no new one may
  appear. The limit is eslint `complexity` 20 on the frontend (64 functions
  over it today) and ruff C901 10 on the backend (32).
- Each is a per-file ceiling. Shrinking is free; an entry back under the
  limit must be deleted, so the lists only shrink.

C901 is measured in a test rather than switched on in ruff.toml: ruff has no
per-function baseline, and a noqa would let a function grow without limit.

Coverage (owner decision D4) is printed with no threshold:
`vitest --coverage` (v8) gives 80% of lines, and the pytest lane ends with
the total for app/, 78%. The bar stays "every regression test seen red".
.coverage is ignored by git and kept out of the image's build context.
2026-10-03 17:18:53 +02:00

44 lines
1.8 KiB
YAML

# DB-backed pytest lane (R6 S3b): an ephemeral Postgres + the test image, wired together so the
# `db` fixture (tests/conftest.py) has a real database. The whole thing is throwaway — the pg data
# lives in tmpfs (RAM) and nothing is persisted. The pure-logic lane still runs WITHOUT this file
# (plain `docker run … python -m pytest` — DB tests skip when no Postgres is reachable).
#
# docker compose -f backend/docker-compose.test.yml up --build --abort-on-container-exit \
# --exit-code-from test
# docker compose -f backend/docker-compose.test.yml down -v
services:
testdb:
image: postgres:16-alpine
environment:
POSTGRES_USER: siftlode
POSTGRES_PASSWORD: siftlode
POSTGRES_DB: siftlode_test
tmpfs:
- /var/lib/postgresql/data # ephemeral + fast; the schema is rebuilt per run
healthcheck:
test: ["CMD-SHELL", "pg_isready -U siftlode -d siftlode_test"]
interval: 1s
timeout: 3s
retries: 30
test:
build:
context: .
dockerfile: Dockerfile.test
depends_on:
testdb:
condition: service_healthy
environment:
DATABASE_URL: postgresql+psycopg://siftlode:siftlode@testdb:5432/siftlode_test
# This lane HAS a Postgres + ffmpeg, so the DB/ffmpeg tests must actually run here: conftest turns
# a would-be silent skip into a hard failure (SIFTLODE_TEST_REQUIRE_DB).
SIFTLODE_TEST_REQUIRE_DB: "1"
volumes:
- ./:/app
working_dir: /app
# The suite, then the coverage total (E32 D4: reported, no threshold). pytest's exit code is the
# lane's — the report is printed either way and never decides it.
command:
- sh
- -c
- 'python -m pytest --cov=app --cov-report= ; rc=$$?; echo ">> backend coverage (app/) $$(python -m coverage report --format=total)% of lines"; exit $$rc'