test: add unit test infrastructure (Docker tester stage + CI)
All checks were successful
Build & Push Docker Image / test (push) Successful in 5m42s
Build & Push Docker Image / build-and-push (push) Successful in 21s

- Add Dockerfile 'tester' stage (FROM builder):
  - Symlinks /usr/local/cuda/lib64/stubs/libcuda.so → libcuda.so.1
    so the test binary can satisfy the dynamic linker without a real GPU
  - Runs `cargo test --release` reusing the cached release build artifacts
    (no recompilation — tests complete in ~6s)
  - docker build --target tester . to run all 30 unit tests

- Add 'test' job to .gitea/workflows/docker-build.yml:
  - Runs before build-and-push (build-and-push needs: test)
  - Builds --target tester with registry build cache
  - Gate: build-and-push only runs when all tests pass

- Add run_tests.sh convenience script for local use:
  - Accepts optional test name filter as first argument
  - Respects CUDA_VERSION / UBUNTU_VERSION env overrides

All 30 unit tests pass:
  error::tests     — 7 tests (OOM detection, ModelNotReady HTTP shape)
  models::tests    — 17 tests (state machine, serialization, retry-after)
  worker::tests    — 6 tests (chunk ranges, silence snap/trim)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
mozempk
2026-05-08 18:20:52 +02:00
parent b191fbe200
commit d0148260e3
3 changed files with 81 additions and 0 deletions

View File

@@ -82,6 +82,27 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
&& cp target/release/whisper-server /usr/local/bin/whisper-server
# ╔══════════════════════════════════════════════════════════╗
# ║ STAGE 1b — tester ║
# ║ Runs unit tests against the release build artifacts ║
# ║ Uses CUDA stubs so tests run without a physical GPU ║
# ║ ║
# ║ Usage: ║
# ║ docker build --target tester . ║
# ╚══════════════════════════════════════════════════════════╝
FROM builder AS tester
# libcuda.so.1 stub — satisfies the dynamic linker without a real driver
RUN ln -sf /usr/local/cuda/lib64/stubs/libcuda.so \
/usr/local/cuda/lib64/stubs/libcuda.so.1
# Reuse the same cache mounts so no recompilation is needed
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/build/target \
LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
cargo test --release
# ╔══════════════════════════════════════════════════════════╗
# ║ STAGE 2 — runtime ║
# ║ Minimal CUDA runtime image — no build tools ║