Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

feat(test-infra): CI-fidelity CPU caps + verified ccache for the local legs

Martin Vogelf71b34fd2805
diff --git a/test-infrastructure/Dockerfile b/test-infrastructure/Dockerfile
index 444b413f3..52b272528 100644
--- a/test-infrastructure/Dockerfile
+++ b/test-infrastructure/Dockerfile
@@ -15,9 +15,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
python3 \
git \
+ ccache \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
+# Verified compiler cache: content-keyed (compiler binary + preprocessed
+# input), so a hit is provably the identical compilation — stale results are
+# impossible by construction. The compose services mount a persistent volume
+# at CCACHE_DIR and route compilers through the Debian masquerade dir.
+ENV CCACHE_COMPILERCHECK=content
+ENV PATH=/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+
WORKDIR /src
# Default: run test.sh with GCC (mirrors CI exactly)
diff --git a/test-infrastructure/docker-compose.yml b/test-infrastructure/docker-compose.yml
index 45418dad8..c95a31d47 100644
--- a/test-infrastructure/docker-compose.yml
+++ b/test-infrastructure/docker-compose.yml
@@ -8,13 +8,22 @@
services:
# ── Linux test (ASan + UBSan + LeakSanitizer) ──────────────
+ # cpus defaults to 4 to mirror the GitHub runners: deadline/starvation bugs
+ # (worker-readiness waits, watcher/subprocess deadlines) only reproduce when
+ # the machine is as constrained as CI — 18 free cores mask them. Override
+ # with CBM_LOCAL_CI_CPUS (0 = unconstrained fast mode).
test:
build:
context: ..
dockerfile: test-infrastructure/Dockerfile
platform: linux/arm64
+ cpus: ${CBM_LOCAL_CI_CPUS:-4.0}
volumes:
- ..:/src
+ - cbm-ccache-arm64:/root/.ccache
+ environment:
+ CCACHE_DIR: /root/.ccache
+ CCACHE_MAXSIZE: 1500M
command: ["CC=gcc", "CXX=g++"]
test-amd64:
@@ -22,8 +31,13 @@ services:
context: ..
dockerfile: test-infrastructure/Dockerfile
platform: linux/amd64
+ cpus: ${CBM_LOCAL_CI_CPUS:-4.0}
volumes:
- ..:/src
+ - cbm-ccache-amd64:/root/.ccache
+ environment:
+ CCACHE_DIR: /root/.ccache
+ CCACHE_MAXSIZE: 1500M
command: ["CC=gcc", "CXX=g++"]
# ── Linux production build (-O2 -Werror) ───────────────────
@@ -172,3 +186,7 @@ services:
dockerfile: test-infrastructure/Dockerfile.lint
volumes:
- ..:/src
+
+volumes:
+ cbm-ccache-arm64:
+ cbm-ccache-amd64:
diff --git a/test-infrastructure/run.sh b/test-infrastructure/run.sh
index 2786f2559..442c9c248 100755
--- a/test-infrastructure/run.sh
+++ b/test-infrastructure/run.sh
@@ -5,9 +5,19 @@
# Linux arm64: test (ASan+LeakSan) + build (-O2) [native, fast]
# Linux amd64: test + build [QEMU, slower]
# Linux portable: Alpine musl static build + smoke [portable binary]
-# Windows: cross-compile with mingw-w64 [compile-check]
+# Windows: cross-compile with mingw-w64 [compile-check; Wine
+# CANNOT reproduce real Windows ACL/token/owner semantics —
+# those need a real Windows VM or the CI legs]
# macOS: run natively (not in Docker)
#
+# CI fidelity: the test containers are capped at 4 CPUs to mirror the GitHub
+# runners — deadline/starvation failures only reproduce under that constraint.
+# CBM_LOCAL_CI_CPUS overrides (0 = unconstrained fast mode). ccache persists
+# in named volumes; entries are content-verified (stale hits impossible), so
+# warm reruns skip unchanged compilation entirely.
+# Run this from the WORKTREE you want tested: the containers mount the repo
+# this script resides in.
+#
# Usage:
# ./test-infrastructure/run.sh # arm64 test+build + portable + Windows
# ./test-infrastructure/run.sh all # above + amd64