fix(ci): collect every test again — gate-first imports + the deps tests actually need

CI has been red since the July layout work: the workflow installed five
light packages while the suite grew tests importing numpy, and the MCP
endpoint tests added fastapi on top. Two fixes:

- panel_layout/screencast_layout imported main (torch, mediapipe) BEFORE
  their ENABLED gate, so even the disabled path paid the heavy import.
  Move the import below the gate: the default path now imports nothing,
  which is what the gate was for.
- The workflow installs exactly what the collected tests import at
  module level, still excluding the ML stack the lazy imports protect.
  List validated against a clean venv: 382 passed, 3 skipped, 0 import
  errors.
This commit is contained in:
juancarlos.cavero 2026-08-04 00:07:29 +02:00
parent 7eab5649a6
commit c200cf787c
3 changed files with 18 additions and 12 deletions

View file

@ -13,13 +13,17 @@ jobs:
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: "3.11" python-version: "3.11"
# Tests only touch light modules (subtitles/hooks/translate/edit_builder # Everything the collected tests import at module level, WITHOUT the
# and the cloud metering helpers), so we install just what they import # heavy ML stack (torch/ultralytics/mediapipe/faster-whisper) — the
# instead of the full requirements.txt (faster-whisper/ultralytics/ # pipeline modules import those lazily behind their feature gates, and
# mediapipe are too heavy for CI). sqlalchemy is needed because # the tests exercise the gated-off paths. numpy+opencv cover the layout
# tests/test_metering_free_plan.py imports cloud.metering. # modules, fastapi/boto3/PyJWT/python-multipart cover importing app.py
# for the MCP endpoint tests, google-genai covers gemini_worker.
- name: Install test dependencies - name: Install test dependencies
run: pip install pytest pillow httpx pydantic sqlalchemy run: >
pip install pytest pillow httpx pydantic sqlalchemy numpy
opencv-python-headless python-dotenv google-genai fastapi boto3
PyJWT email-validator python-multipart
- name: Run tests - name: Run tests
run: pytest tests/ -v run: pytest tests/ -v

View file

@ -218,11 +218,12 @@ def detect_panel_scenes(video_path, scenes, strategies, samples=None):
same reason SPLIT does it: GENERAL already means "more than one face", and same reason SPLIT does it: GENERAL already means "more than one face", and
single-speaker material is most of the corpus and must not be touched. single-speaker material is most of the corpus and must not be touched.
""" """
import cv2
import main as m
if not ENABLED: if not ENABLED:
return {} return {}
# Below the gate on purpose: main pulls torch/mediapipe, and the disabled
# path (the default, and what CI exercises) must not pay that import.
import cv2
import main as m
cap = cv2.VideoCapture(video_path) cap = cv2.VideoCapture(video_path)
if not cap.isOpened(): if not cap.isOpened():

View file

@ -245,11 +245,12 @@ def detect_screencast_scenes(video_path, scenes, strategies, ranges, samples=6):
- WIDE is the blurred layout with side-cropping disabled, for content that - WIDE is the blurred layout with side-cropping disabled, for content that
fills the frame, or that has no presenter to stack. fills the frame, or that has no presenter to stack.
""" """
import cv2
import main as m
if not ENABLED or not ranges: if not ENABLED or not ranges:
return {} return {}
# Below the gate on purpose: main pulls torch/mediapipe, and the disabled
# path (the default, and what CI exercises) must not pay that import.
import cv2
import main as m
cap = cv2.VideoCapture(video_path) cap = cv2.VideoCapture(video_path)
if not cap.isOpened(): if not cap.isOpened():