From f42c38838cd6fbdef3179f1bc26bf035ad976249 Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Mon, 29 Jun 2026 10:44:09 +0000 Subject: [PATCH] CI: run server tests without the pandablocks-dev-container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Python sim/test harness only needs numpy, now provisioned by uv (pyproject.toml + uv.lock, added in #92). Drop the pandablocks-dev-container image and run the regression tests on a plain ubuntu-latest runner. _test.yml: - run `make tests` under `uv run --locked` — the target depends on sim_server and then runs `make -C tests`; uv run puts the venv's `python`/`python3` (with numpy) on PATH for the `#!/usr/bin/env python` harness scripts and asserts uv.lock is in sync; - install valgrind (test_configs runs sim_server under valgrind, via simserver without -n); the container had provided it. The repo Dockerfile installs the same package so `make tests` behaves identically in the local dev container; - override BUILD_DIR to a workspace path (CONFIG.example pins the cross-build convention BUILD_DIR=/build/build-server, which the container gave as a volume); - add timeout-minutes so a stuck socket test can't run for hours. Make the test harness independent of the container's BusyBox nc (ubuntu ships netcat-openbsd, which does not close on stdin EOF without -N and would hang): - run_with_server: probe server readiness with bash /dev/tcp instead of `echo … | nc localhost 8888` in a loop — this loop was the CI hang; - simserver.in / tests/Makefile: bound the "force previous instance away" nc pokes with -w1. Dockerfile: add valgrind (mirrors the workflow apt install) so a developer running `make tests` in the dev container has the same tools as CI. Verified locally de-containerized: test_lut / test_exchange / test_extension pass; test_configs needs valgrind and is covered in CI. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/_test.yml | 44 ++++++++++++++++++++++++++----------- Dockerfile | 5 +++++ simserver.in | 8 ++++--- tests/Makefile | 2 +- tests/run_with_server | 8 +++++-- 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 0f9c98a9..bcab93b4 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -1,25 +1,43 @@ # Run the simulation-server regression tests (tests/Makefile) against a freshly -# built sim_server, inside the pandablocks-dev-container. make is the runner. +# built sim_server, on a plain ubuntu-latest runner. The Python sim/test harness +# only needs numpy, which uv provisions from pyproject.toml + uv.lock — so this no +# longer needs the pandablocks-dev-container image. make stays the runner. +# +# Things the container used to provide, handled here instead: +# - `python` with numpy: the harness scripts are `#!/usr/bin/env python`, so we run +# make under `uv run --locked`, which puts the venv's `python`/`python3` (with +# numpy) on PATH for the harness subprocesses (and asserts uv.lock is in sync). +# - valgrind: the test_configs leak checks run sim_server under valgrind (simserver +# without -n), so install it. (test_exchange uses `simserver -n`, no valgrind.) +# - a writable /build: CONFIG.example pins BUILD_DIR=/build/build-server (the +# cross-build convention), so override BUILD_DIR to a workspace path here. +# +# netcat-openbsd (preinstalled on the runner) covers the remaining `nc` pokes, bounded +# with -w1; the server-readiness probe in run_with_server uses bash /dev/tcp so it does +# not depend on the nc implementation (the container's BusyBox nc had different EOF +# behaviour and was masking this). on: workflow_call: jobs: test: runs-on: ubuntu-latest - container: - image: ghcr.io/pandablocks/pandablocks-dev-container:latest - volumes: - - ${{ github.workspace }}/build:/build - + timeout-minutes: 15 steps: - - name: Checkout Source + - name: Checkout uses: actions/checkout@v5 - with: - path: PandABlocks-server - - name: Run the server regression tests + - name: Install uv + uses: astral-sh/setup-uv@v7 + + # Mirrors the valgrind line in the repo Dockerfile (same package + flags) so + # `make tests` behaves the same in the local dev container as it does here. + - name: Install valgrind (test_configs runs sim_server under valgrind) + run: sudo apt-get update && sudo apt-get install -y --no-install-recommends valgrind + + - name: Build sim_server and run the regression tests run: | - cd PandABlocks-server + set -euo pipefail ln -s CONFIG.example CONFIG - make sim_server - make -C tests + # `make tests` depends on sim_server and then runs `make -C tests`. + uv run --locked make BUILD_DIR="$PWD/build" tests diff --git a/Dockerfile b/Dockerfile index 991306b4..20a3ba07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,11 @@ FROM ghcr.io/diamondlightsource/ubuntu-devcontainer:resolute AS developer # Add any system dependencies for the developer/build environment here. # Candidates: an ARMv7-A cross-compiler toolchain for on-PandA builds; the # native toolchain below is enough for the simulation server and docs. +# npm: drives npx mystmd for the docs build +# valgrind: the test_configs regression tests run sim_server under valgrind +# (mirrors the apt install in .github/workflows/_test.yml so `make +# tests` works the same locally in this container as it does in CI) RUN apt-get update -y && apt-get install -y --no-install-recommends \ npm \ + valgrind \ && apt-get dist-clean diff --git a/simserver.in b/simserver.in index cf931ace..99523c11 100644 --- a/simserver.in +++ b/simserver.in @@ -64,9 +64,11 @@ shift $((OPTIND-1)) # Force any previously running instance of the simulation server to go away -- -# this can happen if sim_server failed on startup for any reason. -nc localhost 9999 /dev/tcp/localhost/8888) 2>/dev/null; do echo connecting... sleep 0.2 done