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.

fix(test-infra): make container legs work from git worktrees

Martin Vogel136685f1a589
diff --git a/test-infrastructure/docker-compose.yml b/test-infrastructure/docker-compose.yml
index bf184f615..f58c78c82 100644
--- a/test-infrastructure/docker-compose.yml
+++ b/test-infrastructure/docker-compose.yml
@@ -20,6 +20,7 @@ services:
platform: linux/arm64
volumes:
- ..:/src
+ - ${CBM_GIT_COMMON_DIR:-..}:${CBM_GIT_COMMON_DIR:-/.cbm-git-noop}:ro
- cbm-build:/src/build
- cbm-fixture-cache:/root/.cache/cbm-test-fixtures
- cbm-ccache-arm64:/root/.ccache
@@ -35,6 +36,7 @@ services:
platform: linux/amd64
volumes:
- ..:/src
+ - ${CBM_GIT_COMMON_DIR:-..}:${CBM_GIT_COMMON_DIR:-/.cbm-git-noop}:ro
- cbm-build:/src/build
- cbm-fixture-cache:/root/.cache/cbm-test-fixtures
- cbm-ccache-amd64:/root/.ccache
@@ -57,6 +59,7 @@ services:
init: true
volumes:
- ..:/src
+ - ${CBM_GIT_COMMON_DIR:-..}:${CBM_GIT_COMMON_DIR:-/.cbm-git-noop}:ro
- cbm-build:/src/build
- cbm-fixture-cache:/root/.cache/cbm-test-fixtures
- cbm-ccache-arm64:/root/.ccache
@@ -79,6 +82,7 @@ services:
init: true
volumes:
- ..:/src
+ - ${CBM_GIT_COMMON_DIR:-..}:${CBM_GIT_COMMON_DIR:-/.cbm-git-noop}:ro
- cbm-build:/src/build
- cbm-fixture-cache:/root/.cache/cbm-test-fixtures
- cbm-ccache-arm64:/root/.ccache
@@ -105,6 +109,7 @@ services:
init: true
volumes:
- ..:/src
+ - ${CBM_GIT_COMMON_DIR:-..}:${CBM_GIT_COMMON_DIR:-/.cbm-git-noop}:ro
- cbm-build:/src/build
- cbm-fixture-cache:/root/.cache/cbm-test-fixtures
- cbm-ccache-amd64:/root/.ccache
@@ -232,6 +237,7 @@ services:
platform: linux/arm64
volumes:
- ..:/src
+ - ${CBM_GIT_COMMON_DIR:-..}:${CBM_GIT_COMMON_DIR:-/.cbm-git-noop}:ro
entrypoint: ["bash", "scripts/test.sh"]
command: ["CC=gcc", "CXX=g++", "BUILD_DIR=build/alpine"]
diff --git a/test-infrastructure/run.sh b/test-infrastructure/run.sh
index 88bc63d4e..a1cd69fbf 100755
--- a/test-infrastructure/run.sh
+++ b/test-infrastructure/run.sh
@@ -98,6 +98,24 @@ trap ci_cleanup EXIT
COMPOSE="docker compose -f $ROOT/test-infrastructure/docker-compose.yml"
+# Worktree checkouts: /src/.git is a pointer file into the primary repo's
+# .git directory, which lives OUTSIDE the ..:/src mount — git inside the
+# container then fails and every git-based contract (e.g. the line-ending
+# guard) dies with "matched no files". Mount the primary .git at the same
+# absolute path, read-only, so the pointer resolves. Plain checkouts leave
+# the variable at its compose-file default (a harmless no-op mount), and
+# container git must also trust the differently-owned mount.
+export CBM_GIT_COMMON_DIR="${CBM_GIT_COMMON_DIR:-}"
+if [ -f "$ROOT/.git" ]; then
+ _git_common="$(git -C "$ROOT" rev-parse --path-format=absolute --git-common-dir 2>/dev/null || true)"
+ if [ -n "$_git_common" ] && [ -d "$_git_common" ]; then
+ export CBM_GIT_COMMON_DIR="$_git_common"
+ fi
+fi
+if [ -z "$CBM_GIT_COMMON_DIR" ]; then
+ unset CBM_GIT_COMMON_DIR
+fi
+
usage() {
cat <<'EOF'
Usage: test-infrastructure/run.sh [leg]