From 2edf3dab49426284233be23dd414ec2b76e84e7e Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 27 Jun 2026 11:22:47 +0200 Subject: [PATCH] ci: assert key IPTV endpoints in the container smoke test (#16) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extend the image smoke test from "serves HTTP" to a real E2E: after HTTP readiness, assert the Jellyfin-facing surfaces on the freshly built image — /iptv/channels.m3u returns 2xx containing #EXTM3U, and /iptv/xmltv.xml returns 2xx containing a --- .gitea/workflows/docker-build.yml | 28 +++++++++++++++++++++++----- docs/ci-cd.md | 11 ++++++++--- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index a45f9dff7..79aadf7d6 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -191,7 +191,7 @@ jobs: cache-from: type=registry,ref=192.168.1.95:3000/timothy/ersatztv:buildcache cache-to: type=registry,ref=192.168.1.95:3000/timothy/ersatztv:buildcache,mode=max,ignore-error=true - - name: Smoke test (HTTP readiness) + - name: Smoke + IPTV E2E (assert key endpoints) if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} run: | IMG="${IMAGE}:${{ steps.meta.outputs.short }}" @@ -223,11 +223,29 @@ jobs: fi sleep 2 done - echo "===== container logs (tail) =====" - docker logs "$NAME" 2>&1 | tail -n 40 || true - echo "=================================" if [ "$ok" != "1" ]; then + echo "===== container logs (tail) ====="; docker logs "$NAME" 2>&1 | tail -n 40 || true echo "Smoke test FAILED: ErsatzTV did not serve HTTP on :8409" exit 1 fi - echo "Smoke test passed: ErsatzTV served HTTP on :8409" + echo "HTTP ready; asserting key IPTV endpoints (ersatztv#16)" + # E2E: assert the real Jellyfin-facing surfaces serve a valid playlist + guide, not just + # that the app answers HTTP. xmltv.xml needs channels.xml, which the scheduler writes a + # few seconds after boot, so poll each endpoint until it returns 2xx with the right shape. + # urlopen() returns only on 2xx (raises on 4xx/5xx), so reaching sys.exit means status OK. + check() { + local path="$1" needle="$2" i + for i in $(seq 1 20); do + if docker exec "$NAME" python3 -c "import urllib.request,sys; b=urllib.request.urlopen('http://localhost:8409$path',timeout=5).read(512).decode('utf-8','replace'); sys.exit(0 if '$needle' in b else 1)" 2>/dev/null; then + echo " OK $path (2xx, contains '$needle')"; return 0 + fi + sleep 3 + done + echo " FAIL $path (no 2xx containing '$needle' within timeout)"; return 1 + } + if check "/iptv/channels.m3u" "#EXTM3U" && check "/iptv/xmltv.xml" "&1 | tail -n 40 || true + exit 1 + fi diff --git a/docs/ci-cd.md b/docs/ci-cd.md index 28a62e3d2..0bffb0fd3 100644 --- a/docs/ci-cd.md +++ b/docs/ci-cd.md @@ -64,9 +64,14 @@ the image build. 4. `docker/build-push-action@v6`: amd64-only, `docker/Dockerfile`, `INFO_VERSION` build-arg, registry layer cache (`type=registry,ref=…:buildcache`, `cache-to … ignore-error=true`). -5. **Smoke test**: pull the just-pushed `:`, run it, and poll ErsatzTV's web - server from inside the container (`docker exec … python3` → `http://localhost:8409/`). - Unique container name + `trap … EXIT` cleanup. Fails if it never serves HTTP. +5. **Smoke + IPTV E2E test**: pull the just-pushed `:`, run it, poll for HTTP + readiness (`docker exec … python3` → `http://localhost:8409/`), then assert the real + Jellyfin-facing surfaces on the freshly built image (ersatztv#16): `/iptv/channels.m3u` + returns 2xx containing `#EXTM3U`, and `/iptv/xmltv.xml` returns 2xx containing a `