Files
ukmesh/scripts/check_external_consumer_sql.py
hermes-gadget 79190f8382 fix(ci): ship the external-consumer SQL checker with the worker image (#196)
The Workers and Compose job runs the worker suite inside the built image
(`python -m unittest discover -s /app/tests`). The relation-qualification
test resolved the checker as `<repo>/scripts/check_external_consumer_sql.py`
via `Path(__file__).parents[2]`, which inside the container is `/scripts`,
and the image only carries `viewshed-worker/`, so the job died with
`ModuleNotFoundError: check_external_consumer_sql` before any test ran.

The image builds with `context: viewshed-worker`, so a repo-level `scripts/`
file cannot be COPYed in without widening the build context (and the release
workflow). Move the implementation next to the worker (`viewshed-worker/
check_external_consumer_sql.py`), leave a thin shim at the old path so
`backend`'s `test:external-consumers:sql` keeps working from a checkout, and
add the module to the Dockerfile COPY.

The test now resolves the module from the worker root, and a new in-image
test asserts the checker imports from that root, so dropping it from the
image fails with a named test instead of a bare import error.
2026-11-05 16:44:29 +00:00

30 lines
924 B
Python

#!/usr/bin/env python3
"""Repo-level entry point for the external-consumer SQL checker.
The implementation lives in ``viewshed-worker/`` because that is the tree the
worker image builds from: the worker's own test suite imports it inside the
container, so it has to be COPYed into the image. This shim keeps the
documented ``python3 scripts/check_external_consumer_sql.py`` invocation (used
by ``backend/package.json``) working from a repo checkout.
"""
from __future__ import annotations
import sys
from pathlib import Path
_WORKER_ROOT = Path(__file__).resolve().parents[1] / "viewshed-worker"
if str(_WORKER_ROOT) not in sys.path:
sys.path.insert(0, str(_WORKER_ROOT))
from check_external_consumer_sql import ( # noqa: E402
MOVED_RELATIONS,
main,
scan_roots,
scan_text,
)
__all__ = ["MOVED_RELATIONS", "main", "scan_roots", "scan_text"]
if __name__ == "__main__":
raise SystemExit(main())