# The default test runner — the image this actor PUBLISHES for a component, never its own image.
#
# SHIPPED IN THE WHEEL, NOT IN EVERY TESTING REPO. The hand-written actor this package replaces kept
# this file in its own repository, where it named nothing about the capability: a Python base, a
# pytest, and a CMD. It is the contract between this actor and the orchestrating actor that runs
# what it publishes, so it lives with the actor. A component whose sidecar entry declares no
# `runner:` is built with this one; `buildctl --local dockerfile=` reads it straight out of the
# installed package (see handler.py's `runner_dir`).
#
# Static and task-agnostic on purpose: `_publish_test_image` builds this same Dockerfile for every
# task, pointing its build CONTEXT at that component's own persistent, accumulated tests root —
#     buildctl build --local context=<component tests root> --local dockerfile=<this folder>
# — every prior task's tests plus this one's, so the published image always runs the full
# regression suite. Nothing here ever needs to know a task id or a capability.
#
# Run by the orchestrating actor's own Job: the generated tests read their target component's base
# URL from an environment variable named <COMPONENT>_URL (uppercase, e.g. BACKEND_URL), or whichever
# variable the agreed acceptance surface named — set by that Job to the in-namespace service
# address, never baked into this image.
#
# WHAT IT CARRIES, AND WHEN TO DECLARE YOUR OWN. pytest to run the suite; requests for HTTP
# handles; aio-pika for event handles on an AMQP bus. A capability whose tests need anything else
# declares `runner:` on that component and owns the file — keeping its CMD a pytest run, because
# that is what the orchestrating actor reads a verdict from.
FROM python:3.12-slim

RUN pip install --no-cache-dir "pytest==8.*" "requests==2.*" "aio-pika==9.*"

WORKDIR /tests
COPY . /tests

CMD ["pytest", "-v", "--tb=line"]
