# Tier 1: Unit tests — pure Python, no services, no DB, no Redis
# Covers: shared/, artdag/core/, artdag/l1/tests/, artdag/l1/sexp_effects/
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PYTHONPATH=/app

WORKDIR /app

# Node.js for sx.js parity tests
RUN apt-get update && apt-get install -y --no-install-recommends nodejs && \
    rm -rf /var/lib/apt/lists/*

# Install shared deps (includes pytest, pytest-asyncio)
COPY shared/requirements.txt ./requirements-shared.txt
RUN pip install --no-cache-dir -r requirements-shared.txt pytest-watch

# Install artdag core as editable package
COPY artdag/core/ ./artdag/core/
RUN pip install --no-cache-dir -e artdag/core/[dev]

# Install artdag common
COPY artdag/common/ ./artdag/common/
RUN pip install --no-cache-dir -e artdag/common/

# Install L1 deps that unit tests need (not the heavy ones)
COPY artdag/l1/requirements.txt ./requirements-l1.txt
RUN pip install --no-cache-dir -r requirements-l1.txt 2>/dev/null || true

# Copy test subjects
COPY shared/ ./shared/
COPY artdag/l1/tests/ ./artdag/l1/tests/
COPY artdag/l1/sexp_effects/ ./artdag/l1/sexp_effects/
COPY artdag/l1/app/ ./artdag/l1/app/
COPY artdag/l1/database.py ./artdag/l1/database.py
COPY artdag/l1/ipfs_client.py ./artdag/l1/ipfs_client.py
COPY artdag/l1/storage_providers.py ./artdag/l1/storage_providers.py
COPY artdag/l1/cache_manager.py ./artdag/l1/cache_manager.py
COPY artdag/l1/claiming.py ./artdag/l1/claiming.py
COPY artdag/l1/path_registry.py ./artdag/l1/path_registry.py
COPY artdag/l1/celery_app.py ./artdag/l1/celery_app.py
COPY artdag/l1/pyproject.toml ./artdag/l1/pyproject.toml

# Default: run all unit tests
CMD ["python", "-m", "pytest", \
     "shared/", \
     "artdag/core/tests/", \
     "artdag/core/artdag/sexp/", \
     "artdag/l1/tests/", \
     "artdag/l1/sexp_effects/", \
     "-v", "--tb=short", \
     "--ignore=artdag/l1/tests/test_jax_primitives.py", \
     "--ignore=artdag/l1/tests/test_jax_pipeline_integration.py", \
     "-k", "not gpu and not cuda"]
