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.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Add Alpine portable as 4th local test platform, fix musl compat
Martin Vogel966206309064
diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.ymlindex cf90d7067..bf7d4d5f4 100644--- a/.github/workflows/_build.yml+++ b/.github/workflows/_build.yml@@ -136,8 +136,9 @@ jobs:path: "*.zip"build-linux-portable:- # Static musl builds — uses musl-tools on Ubuntu (not Alpine containers,- # which break on ARM64 due to GitHub Actions JS action limitation).+ # Static musl builds via `docker run alpine` inside Ubuntu runners.+ # Can't use `container: alpine` on ARM64 (GitHub Actions JS actions break).+ # Checkout happens on Ubuntu host, build runs inside Alpine container.strategy:fail-fast: falsematrix:@@ -147,39 +148,35 @@ jobs:- arch: arm64runner: ubuntu-24.04-armruns-on: ${{ matrix.runner }}- timeout-minutes: 15+ timeout-minutes: 20steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- - name: Install musl build deps- run: |- sudo apt-get update- sudo apt-get install -y musl-tools zlib1g-dev nodejs npm-- - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0- with:- node-version: "22"-- - name: Build standard binary (static musl)- run: scripts/build.sh ${{ inputs.version && format('--version {0}', inputs.version) || '' }} CC=musl-gcc CXX=g++ STATIC=1-- - name: Verify static linking- run: file build/c/codebase-memory-mcp | grep -q "statically linked"-- - name: Archive standard binary+ - name: Build standard binary (Alpine static)run: |+ docker run --rm -v "$PWD:/src" -w /src alpine:3.21 sh -c "+ apk add --no-cache build-base linux-headers zlib-dev zlib-static nodejs npm bash &&+ bash scripts/build.sh ${VERSION_FLAG} CC=gcc CXX=g++ STATIC=1+ "+ file build/c/codebase-memory-mcp | grep -q "statically linked"+ echo "=== Verified: statically linked ==="cp LICENSE install.sh build/c/tar -czf codebase-memory-mcp-linux-${{ matrix.arch }}-portable.tar.gz \-C build/c codebase-memory-mcp LICENSE install.sh+ env:+ VERSION_FLAG: ${{ inputs.version && format('--version {0}', inputs.version) || '' }}- - name: Build UI binary (static musl)- run: scripts/build.sh --with-ui ${{ inputs.version && format('--version {0}', inputs.version) || '' }} CC=musl-gcc CXX=g++ STATIC=1-- - name: Archive UI binary+ - name: Build UI binary (Alpine static)run: |+ docker run --rm -v "$PWD:/src" -w /src alpine:3.21 sh -c "+ apk add --no-cache build-base linux-headers zlib-dev zlib-static nodejs npm bash &&+ bash scripts/build.sh --with-ui ${VERSION_FLAG} CC=gcc CXX=g++ STATIC=1+ "cp LICENSE install.sh build/c/tar -czf codebase-memory-mcp-ui-linux-${{ matrix.arch }}-portable.tar.gz \-C build/c codebase-memory-mcp LICENSE install.sh+ env:+ VERSION_FLAG: ${{ inputs.version && format('--version {0}', inputs.version) || '' }}- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0with:diff --git a/Makefile.cbm b/Makefile.cbmindex fd5ab9323..c553c3e8a 100644--- a/Makefile.cbm+++ b/Makefile.cbm@@ -81,7 +81,12 @@ ifeq ($(IS_MINGW),yes)WIN32_LIBS := -lws2_32 -lpsapi -Wl,--allow-multiple-definition -Wl,--stack,8388608 -staticendif-LDFLAGS = -lm -lstdc++ -lpthread -lz $(LIBGIT2_LIBS) $(WIN32_LIBS)+# STATIC=1 produces a fully static binary (for Alpine/musl portable builds)+ifeq ($(STATIC),1)+STATIC_FLAGS := -static+endif++LDFLAGS = -lm -lstdc++ -lpthread -lz $(LIBGIT2_LIBS) $(WIN32_LIBS) $(STATIC_FLAGS)LDFLAGS_TEST = -lm -lstdc++ -lpthread -lz $(SANITIZE) $(LIBGIT2_LIBS) $(WIN32_LIBS)LDFLAGS_TSAN = -lm -lstdc++ -lpthread -lz -fsanitize=thread $(LIBGIT2_LIBS) $(WIN32_LIBS)diff --git a/src/mcp/mcp.c b/src/mcp/mcp.cindex 976f269e8..e69a21f29 100644--- a/src/mcp/mcp.c+++ b/src/mcp/mcp.c@@ -58,8 +58,6 @@ enum {#include <process.h> /* _getpid */#else#include <unistd.h>-#include <sys/unistd.h>-#include <sys/poll.h>#include <poll.h>#include <fcntl.h>#endifdiff --git a/test-infrastructure/Dockerfile.alpine b/test-infrastructure/Dockerfile.alpinenew file mode 100644index 000000000..00f1e51c8--- /dev/null+++ b/test-infrastructure/Dockerfile.alpine@@ -0,0 +1,26 @@+# Mirrors the Alpine CI environment for portable (musl static) builds.+# - Alpine 3.21 with musl libc+# - GCC + static zlib for fully static binaries+# - Produces portable Linux binaries that run on any distro+#+# Build: docker build -f test-infrastructure/Dockerfile.alpine -t cbm-alpine test-infrastructure/+# Run: docker run --rm -v $(pwd):/src cbm-alpine++FROM alpine:3.21++RUN apk add --no-cache \+ build-base \+ linux-headers \+ zlib-dev \+ zlib-static \+ bash \+ git \+ python3 \+ nodejs \+ npm \+ ca-certificates++WORKDIR /src++ENTRYPOINT ["bash", "scripts/build.sh"]+CMD ["CC=gcc", "CXX=g++", "STATIC=1"]diff --git a/test-infrastructure/docker-compose.yml b/test-infrastructure/docker-compose.ymlindex 7ab21cb49..45418dad8 100644--- a/test-infrastructure/docker-compose.yml+++ b/test-infrastructure/docker-compose.yml@@ -129,6 +129,42 @@ services:mv build/c/codebase-memory-mcp build/c/codebase-memory-mcp.exe 2>/dev/null || true &&CBM_DIAGNOSTICS=1 WINEDEBUG=-all scripts/soak-test.sh ./build/c/codebase-memory-mcp.exe 10+ # ── Linux portable (Alpine musl static) ────────────────────+ test-portable:+ build:+ context: ..+ dockerfile: test-infrastructure/Dockerfile.alpine+ platform: linux/arm64+ volumes:+ - ..:/src+ entrypoint: ["bash", "scripts/test.sh"]+ command: ["CC=gcc", "CXX=g++"]++ build-portable:+ build:+ context: ..+ dockerfile: test-infrastructure/Dockerfile.alpine+ platform: linux/arm64+ volumes:+ - ..:/src+ entrypoint: ["bash", "scripts/build.sh"]+ command: ["CC=gcc", "CXX=g++", "STATIC=1"]++ smoke-portable:+ build:+ context: ..+ dockerfile: test-infrastructure/Dockerfile.alpine+ platform: linux/arm64+ volumes:+ - ..:/src+ entrypoint: ["bash", "-c"]+ command:+ - |+ scripts/build.sh CC=gcc CXX=g++ STATIC=1 &&+ file build/c/codebase-memory-mcp | grep -q "statically linked" &&+ echo "=== Verified: statically linked ===" &&+ scripts/smoke-test.sh ./build/c/codebase-memory-mcp+# ── Lint ────────────────────────────────────────────────────lint:build:diff --git a/test-infrastructure/run.sh b/test-infrastructure/run.shindex 35cb18943..32b1826db 100755--- a/test-infrastructure/run.sh+++ b/test-infrastructure/run.sh@@ -2,14 +2,16 @@# Local CI — test all platforms before pushing.## Coverage:-# Linux arm64: test (ASan+LeakSan) + build (-O2) [native, fast]-# Linux amd64: test + build [QEMU, slower]-# Windows: cross-compile with mingw-w64 [compile-check]-# macOS: run natively (not in Docker)+# 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]+# macOS: run natively (not in Docker)## Usage:-# ./test-infrastructure/run.sh # Linux test+build + Windows compile+# ./test-infrastructure/run.sh # arm64 test+build + portable + Windows# ./test-infrastructure/run.sh all # above + amd64+# ./test-infrastructure/run.sh portable # Alpine portable build + smoke only# ./test-infrastructure/run.sh windows # Windows cross-compile only# ./test-infrastructure/run.sh test # Linux arm64 test only (no perf)# ./test-infrastructure/run.sh perf # Linux arm64 perf/incremental only@@ -29,6 +31,8 @@ case "${1:-full}" in$COMPOSE run --rm buildecho "=== Linux arm64: smoke test ==="$COMPOSE run --rm smoke+ echo "=== Linux portable: Alpine static build + smoke ==="+ $COMPOSE run --rm smoke-portableecho "=== Windows: cross-compile ==="$COMPOSE run --rm build-windowsecho "=== All passed ==="@@ -46,9 +50,17 @@ case "${1:-full}" in$COMPOSE run --rm build;;smoke)- echo "=== Linux arm64: smoke test (build + run all 7 phases) ==="+ echo "=== Linux arm64: smoke test (build + run all phases) ==="$COMPOSE run --rm smoke;;+ portable)+ echo "=== Linux portable: Alpine static build + smoke ==="+ $COMPOSE run --rm smoke-portable+ ;;+ portable-test)+ echo "=== Linux portable: Alpine test (ASan + LeakSan) ==="+ $COMPOSE run --rm -e CBM_SKIP_PERF=1 test-portable+ ;;windows)echo "=== Windows: cross-compile + smoke (Wine) ==="$COMPOSE run --rm smoke-windows@@ -71,6 +83,8 @@ case "${1:-full}" in$COMPOSE run --rm -e CBM_SKIP_PERF=1 test$COMPOSE run --rm build$COMPOSE run --rm smoke+ echo "=== Linux portable: Alpine static build + smoke ==="+ $COMPOSE run --rm smoke-portableecho "=== Linux amd64: test + build + smoke ==="$COMPOSE run --rm -e CBM_SKIP_PERF=1 test-amd64$COMPOSE run --rm build-amd64@@ -87,8 +101,12 @@ case "${1:-full}" inecho "=== Debug shell (Linux arm64) ==="$COMPOSE run --rm --entrypoint bash test;;+ shell-alpine)+ echo "=== Debug shell (Alpine) ==="+ $COMPOSE run --rm --entrypoint bash test-portable+ ;;*)- echo "Usage: $0 {full|test|build|smoke|perf|windows|amd64|all|lint|shell}"+ echo "Usage: $0 {full|test|build|smoke|portable|portable-test|windows|amd64|all|lint|shell|shell-alpine}"exit 1;;esac