From 583168a738de2293053c340f746f3ecb8e10ab36 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 7 Sep 2026 20:45:04 +0000 Subject: [PATCH 1/2] CI: Testsuite als GitHub-Actions-Workflow Bisher lief die Suite nur lokal und in der Docker-Teststage; am Pull Request war davon nichts zu sehen. Der neue Workflow laeuft bei jedem PR und bei jedem Push nach main und macht das Ergebnis als Check sichtbar. Zwei Jobs mit unterschiedlichem Zweck: - pytest auf einem einfachen Runner (Python 3.13, pip-Cache) fuer schnelle Rueckmeldung. - docker build --target test: dieselbe Suite im gepinnten python:3.13-slim-Image. Nur dort faellt ein Version-Pin auf, der sich nicht mehr aufloest, oder eine neue Quelldatei, die in der expliziten COPY-Liste des Dockerfiles fehlt. Der pytest-Job installiert bewusst keine apt-Pakete: keines der Runtime-Wheels linkt gegen libGL oder libglib (mit ldd geprueft), das Dockerfile braucht sie nur, weil das slim-Image fast nichts mitbringt. Gleichzeitige Laeufe auf derselben Ref brechen sich gegenseitig ab. pyrefly bleibt bewusst draussen (siehe AGENTS.md). README bekommt ein Status-Badge und einen CI-Abschnitt, AGENTS.md die Begruendung. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01MBcmgApsSKtRaJtLQRhP2M --- .github/workflows/tests.yml | 65 +++++++++++++++++++++++++++++++++++++ AGENTS.md | 3 +- README.md | 14 ++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..8e218d0 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,65 @@ +# Runs the test suite on GitHub so its result is visible as a check on every +# pull request. Two jobs on purpose: +# +# pytest - fast feedback on a plain runner (~1 min). +# docker - the same suite inside the pinned python:3.13-slim image, which is +# the deploy path. It is the only place that catches a broken +# version pin from requirements.txt or a new source file missing +# from the Dockerfile's explicit COPY list (see AGENTS.md). +# +# No apt step in the pytest job: none of the runtime wheels link against libGL +# or libglib, the Dockerfile installs those only because python:3.13-slim ships +# with almost nothing. +name: Tests + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +# A new push supersedes the previous run on the same ref; no point in paying +# for CI on a commit nobody will look at any more. +concurrency: + group: tests-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + pytest: + name: pytest (Python 3.13) + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v5 + + # Python 3.13 exactly: manifold3d and pymeshfix have no wheels for 3.14, + # and the requirements are pinned against 3.13. + - uses: actions/setup-python@v6 + with: + python-version: "3.13" + cache: pip + cache-dependency-path: | + requirements.txt + requirements-dev.txt + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + + - name: Run test suite + run: pytest + + docker: + name: Docker test stage + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v5 + + # The test stage runs pytest during the build: a red test fails the build. + - name: Build test stage + run: docker build --target test . diff --git a/AGENTS.md b/AGENTS.md index 93ff3d5..3b53805 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,7 +11,7 @@ High-signal context for OpenCode sessions in this repo. - **Python 3.13 strictly required.** `manifold3d` and `pymeshfix` have no wheels for 3.14 yet. - Runtime deps live in `requirements.txt`, test-only deps in `requirements-dev.txt` (which includes the former via `-r`). `scikit-image` is a runtime dep despite never being imported directly: `trimesh` imports it lazily inside `matrix_to_marching_cubes`, so pip won't pull it in on its own. Don't "clean it up". -- No linters or build system are configured. Do not invent them unless asked. +- No linters or build system are configured. Do not invent them unless asked. `pyrefly.toml` is checked in for local type checks (`pyrefly check`), but it is deliberately **not** part of CI — keep it that way unless asked. - **The runtime image must ship `.streamlit/config.toml`.** The Dockerfile copies files individually (not `COPY . .`), and the pinned dark theme lives in that file. Without it the container falls back to the light theme while the custom CSS in `app.py` stays dark-tuned — sidebar labels then render unreadable. Any new file the app reads at runtime has to be added to the `runtime` stage explicitly. ## Testing @@ -21,6 +21,7 @@ High-signal context for OpenCode sessions in this repo. - **After every code change, run the tests.** If the suite fails, fix the regression before considering the change done. - **Extend the suite when you add or modify behavior.** New functions, new branches, new edge cases or bug fixes must come with matching tests. Keep test docstrings and comments in English per the language convention below. - Shared fixtures (cube/sphere STL, fast config) live in `tests/conftest.py` — reuse them instead of regenerating geometry. +- **CI is `.github/workflows/tests.yml`** (pull requests and pushes to `main`): one job runs `pytest` on a plain runner with Python 3.13, a second builds `docker build --target test .`. The Docker job is not redundant — it is what catches a version pin that no longer resolves on `python:3.13-slim` and a new source file missing from the Dockerfile's explicit `COPY` list. Adding a source file therefore means touching the Dockerfile in the same change, or CI goes red. The pytest job deliberately installs no apt packages: no runtime wheel links against libGL or libglib (checked with `ldd`), the Dockerfile needs them only because the slim image ships with almost nothing. ## Language convention diff --git a/README.md b/README.md index c51965c..3a2d7e9 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ upload STL → compute inlay → print

+ Tests License: AGPL v3 Python 3.13 UI: English or German @@ -268,6 +269,19 @@ sphere fixtures. `tests/test_app_render.py` renders `app.py` through Streamlit's `AppTest` in both languages, which is what makes the otherwise unimportable frontend testable. +### Continuous integration + +`.github/workflows/tests.yml` runs on every pull request and on every push to +`main`, so the result shows up as a check on the pull request: + +| Job | What it does | Why | +|---|---|---| +| `pytest (Python 3.13)` | Installs `requirements-dev.txt` on a plain runner and runs the suite | Fast feedback (~1 min) | +| `Docker test stage` | `docker build --target test .` | Runs the same suite inside the pinned `python:3.13-slim` image — the only place a broken version pin or a source file missing from the Dockerfile's `COPY` list shows up | + +Runs on the same branch supersede each other, so an outdated commit does not +keep a runner busy. + --- ## 🔧 Pipeline From 53b0980136626928a3ecc5be9f017e3c2a58c35b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 7 Sep 2026 20:55:09 +0000 Subject: [PATCH 2/2] Docker-Teststage: fehlende Dateien ergaenzen Der neue CI-Job hat im ersten Lauf genau das gefunden, wofuer er da ist: `docker build --target test .` liess vier Tests aus tests/test_streamlit_config.py fehlschlagen, waehrend dieselbe Suite lokal gruen war. Die Teststage kopiert ihre Dateien einzeln und hatte weder .streamlit/config.toml noch das Dockerfile dabei - beide liest der Test. Der Bruch ist aelter als dieser Branch: die Stage war schon auf main so, das README dokumentiert den Befehl aber als funktionierend. - Dockerfile: .streamlit/ und Dockerfile in die Teststage kopieren. Die Stage wird nicht ausgeliefert, im Laufzeit-Image landet nichts davon. - .dockerignore: Dockerfile-Ausschluss entfernt, sonst waere die Datei gar nicht erst im Build-Kontext. Keine Stage macht `COPY . .`, sie landet also nur dort, wo sie ausdruecklich genannt wird. - Kommentare der beruehrten Stage auf Englisch (Sprachkonvention). - AGENTS.md: die COPY-Regel gilt auch fuer die Teststage. Verifiziert durch Nachstellen der Stage in einem leeren Verzeichnis: mit der alten Dateiliste 4 failed, mit der neuen 276 passed. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01MBcmgApsSKtRaJtLQRhP2M --- .dockerignore | 5 ++++- AGENTS.md | 4 ++-- Dockerfile | 13 ++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 0480658..4e2878d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,6 +5,9 @@ __pycache__ *.pyc data *.md -Dockerfile +# Dockerfile stays IN the context on purpose: tests/test_streamlit_config.py +# reads it to check that the runtime stage copies .streamlit/, so the test +# stage has to copy it in. No stage does `COPY . .`, so it only ever lands +# where it is named explicitly - never in the runtime image. docker-compose.yml .dockerignore \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md index 3b53805..85fb948 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,7 +12,7 @@ High-signal context for OpenCode sessions in this repo. - **Python 3.13 strictly required.** `manifold3d` and `pymeshfix` have no wheels for 3.14 yet. - Runtime deps live in `requirements.txt`, test-only deps in `requirements-dev.txt` (which includes the former via `-r`). `scikit-image` is a runtime dep despite never being imported directly: `trimesh` imports it lazily inside `matrix_to_marching_cubes`, so pip won't pull it in on its own. Don't "clean it up". - No linters or build system are configured. Do not invent them unless asked. `pyrefly.toml` is checked in for local type checks (`pyrefly check`), but it is deliberately **not** part of CI — keep it that way unless asked. -- **The runtime image must ship `.streamlit/config.toml`.** The Dockerfile copies files individually (not `COPY . .`), and the pinned dark theme lives in that file. Without it the container falls back to the light theme while the custom CSS in `app.py` stays dark-tuned — sidebar labels then render unreadable. Any new file the app reads at runtime has to be added to the `runtime` stage explicitly. +- **The runtime image must ship `.streamlit/config.toml`.** The Dockerfile copies files individually (not `COPY . .`), and the pinned dark theme lives in that file. Without it the container falls back to the light theme while the custom CSS in `app.py` stays dark-tuned — sidebar labels then render unreadable. Any new file the app reads at runtime has to be added to the `runtime` stage explicitly. **The same holds for the `test` stage:** it copies its files individually too, so a repo file the tests read has to be named there *and* must not be excluded by `.dockerignore` — which is why the `Dockerfile` deliberately stays in the build context (`tests/test_streamlit_config.py` reads it). Miss one and the tests pass locally but fail inside the image. ## Testing @@ -21,7 +21,7 @@ High-signal context for OpenCode sessions in this repo. - **After every code change, run the tests.** If the suite fails, fix the regression before considering the change done. - **Extend the suite when you add or modify behavior.** New functions, new branches, new edge cases or bug fixes must come with matching tests. Keep test docstrings and comments in English per the language convention below. - Shared fixtures (cube/sphere STL, fast config) live in `tests/conftest.py` — reuse them instead of regenerating geometry. -- **CI is `.github/workflows/tests.yml`** (pull requests and pushes to `main`): one job runs `pytest` on a plain runner with Python 3.13, a second builds `docker build --target test .`. The Docker job is not redundant — it is what catches a version pin that no longer resolves on `python:3.13-slim` and a new source file missing from the Dockerfile's explicit `COPY` list. Adding a source file therefore means touching the Dockerfile in the same change, or CI goes red. The pytest job deliberately installs no apt packages: no runtime wheel links against libGL or libglib (checked with `ldd`), the Dockerfile needs them only because the slim image ships with almost nothing. +- **CI is `.github/workflows/tests.yml`** (pull requests and pushes to `main`): one job runs `pytest` on a plain runner with Python 3.13, a second builds `docker build --target test .`. The Docker job is not redundant — it is what catches a version pin that no longer resolves on `python:3.13-slim` and a new source file missing from the Dockerfile's explicit `COPY` list. Its very first run proved the point: `.streamlit/` and the `Dockerfile` were missing from the `test` stage, so `docker build --target test .` had been failing four tests in `test_streamlit_config.py` while the same suite was green locally. Adding a source file therefore means touching the Dockerfile in the same change, or CI goes red. The pytest job deliberately installs no apt packages: no runtime wheel links against libGL or libglib (checked with `ldd`), the Dockerfile needs them only because the slim image ships with almost nothing. ## Language convention diff --git a/Dockerfile b/Dockerfile index ad14be2..ed2d782 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,15 +16,22 @@ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -# --- Teststage -------------------------------------------------------------- -# Laeuft die Suite waehrend des Builds; ein roter Test bricht den Build ab. -# Nicht Teil von `runtime`, tests/ landen also nie im Deploy-Image. +# --- Test stage ------------------------------------------------------------- +# Runs the suite during the build; a red test fails the build. +# Not part of `runtime`, so tests/ never end up in the deploy image. FROM base AS test COPY requirements-dev.txt ./ RUN pip install --no-cache-dir -r requirements-dev.txt COPY pytest.ini inlayer.py app.py app_helpers.py i18n.py ./ COPY tests/ ./tests/ +# tests/test_streamlit_config.py reads both of these: the config whose theme and +# upload limit it pins down, and the Dockerfile itself to verify the runtime +# stage's COPY line. Without them four tests fail inside the image only - which +# is exactly the drift the containerised run is meant to catch. +# `.dockerignore` keeps the Dockerfile in the context for this reason. +COPY .streamlit/ ./.streamlit/ +COPY Dockerfile ./ RUN python -m pytest -q