test: add unit test infrastructure (Docker tester stage + CI)
- 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:
@@ -18,7 +18,30 @@ env:
|
||||
UBUNTU_VERSION: ${{ vars.UBUNTU_VERSION || '22.04' }}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Run unit tests
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
target: tester
|
||||
push: false
|
||||
build-args: |
|
||||
CUDA_VERSION=${{ env.CUDA_VERSION }}
|
||||
UBUNTU_VERSION=${{ env.UBUNTU_VERSION }}
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
|
||||
|
||||
build-and-push:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
Reference in New Issue
Block a user