clipwright/.github/workflows/ci.yml
pedro-bento d03ef799f4
All checks were successful
CI / unit (pull_request) Successful in 45s
CI / backend-e2e (pull_request) Successful in 1m16s
CI / dashboard-e2e (pull_request) Successful in 2m26s
test: unskip the main-module unit tests and enable the real-backend browser lane
- tests/conftest.py installs minimal ultralytics/mediapipe stand-ins only when
  the real packages are absent, so clipwright.pipeline.main imports in the thin
  unit env instead of pytest.importorskip skipping 15 modules (63 tests). Unit
  suite is now 779 passed / 0 skipped.
- requirements-test.txt pins uvicorn==0.46.0 (the real-backend server).
- dashboard: vite preview proxies /api,/videos,/thumbnails to a locally-launched
  backend; Playwright gains a gated (CW_E2E_REAL) real project + uvicorn
  webServer running the pipeline stub_env; real-backend.spec.js drives the real
  upload->process->clip flow. CI dashboard job installs the backend test deps.
- Verified: real lane 20 passed twice in the CI container; mock-only 19 passed
  without the flag; backend unit/API/pipeline 779/209/127.
2026-10-05 10:46:45 +01:00

96 lines
4.1 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
env:
PYTHONHASHSEED: "0"
TZ: UTC
PIP_DISABLE_PIP_VERSION_CHECK: "1"
jobs:
# Fast unit suite. No ffmpeg, no ML stack.
unit:
runs-on: ubuntu-latest
timeout-minutes: 15
# The Forgejo runner cannot provision Python 3.11 via actions/setup-python
# ("Version 3.11 was not found in the local cache"), so every job runs in a
# container that already has Python 3.11. It must also ship Node and git:
# the runner executes JS actions (actions/checkout) by invoking `node`
# inside the job container.
container: nikolaik/python-nodejs:python3.11-nodejs20
steps:
- uses: actions/checkout@v4
# scenedetect (in requirements-test.txt) pulls the full opencv-python,
# whose cv2 binary links libGL.so.1 — absent from the base image. The
# pipeline modules the unit tests import need it at import time.
- name: Install opencv system libs
run: apt-get update -qq && apt-get install -y -qq --no-install-recommends libgl1
- name: Install test dependencies
run: pip install -r requirements-test.txt
- name: Run unit tests
# Exclude the E2E tree from *collection*: `-m "not e2e"` only filters
# execution, but pytest still imports every module to collect it, and
# the pipeline E2E modules import the pipeline (tqdm/scenedetect/ML),
# which would pull in fixtures the unit suite does not exercise.
run: pytest tests/ --ignore=tests/e2e -m "not e2e" -q
# Backend E2E: API + pipeline. ffmpeg/ffprobe must be installed in-job.
# requirements-test.txt already carries pytest-asyncio/asgi-lifespan/
# pytest-timeout and the pure-Python scene engine. API and pipeline run as
# separate processes so the pipeline tests' fake `clipwright.pipeline.main`
# can never leak into the API process. No ML stack: detectors are stubbed,
# only ffmpeg is real.
backend-e2e:
runs-on: ubuntu-latest
timeout-minutes: 30
container: nikolaik/python-nodejs:python3.11-nodejs20
steps:
- uses: actions/checkout@v4
- name: Install ffmpeg
run: apt-get update -qq && apt-get install -y -qq --no-install-recommends ffmpeg && ffmpeg -version | head -1
- name: Install test dependencies
run: pip install -r requirements-test.txt
- name: Run API E2E
run: pytest tests/e2e/api -m e2e -q --timeout=120
- name: Run pipeline E2E (non-ML)
run: pytest tests/e2e/pipeline -m "e2e and not ml" -q --timeout=120
# Dashboard E2E (Playwright). The container already ships Node 20 + npm + git,
# so actions/setup-node and actions/cache are deliberately NOT used (their
# Node download / cache endpoints time out against the act runner:
# "connect ETIMEDOUT 172.27.0.4:41759"). Playwright is retry-free by config;
# install browsers fresh each run.
dashboard-e2e:
runs-on: ubuntu-latest
timeout-minutes: 30
container: nikolaik/python-nodejs:python3.11-nodejs20
# Turn on the real-backend lane: Playwright's second webServer boots a real
# uvicorn (pipeline stub_env) and the `real` project drives it.
env:
CW_E2E_REAL: "1"
defaults:
run:
working-directory: dashboard
steps:
- uses: actions/checkout@v4
# ffmpeg builds the media fixture and renders the real pipeline's clips;
# libgl1 satisfies opencv (pulled by scenedetect) at import time.
- name: Install ffmpeg + opencv system libs
run: apt-get update -qq && apt-get install -y -qq --no-install-recommends ffmpeg libgl1
# Backend deps for the uvicorn server the real lane launches (uvicorn is
# pinned in requirements-test.txt alongside fastapi/scenedetect/...).
- name: Install backend test dependencies
run: pip install -r ../requirements-test.txt
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Lint
run: npm run lint
- name: Build
run: npm run build
- name: Browser E2E
run: npm run test:e2e