From 5b5c2b5819ebd35d50000dfedc79c7a1713755ca Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sat, 31 Oct 2026 03:33:10 -0500 Subject: [PATCH] mcpx: add darwin/arm64 test-compile gate (#1988) Nothing in CI compiled mcpx test packages for darwin, so a Linux-only test constant (syscall.SOCK_CLOEXEC in internal/daemon, #237) was invisible until a Mac run. scripts/darwin-compile-check.sh cross-compiles go build ./... plus every test binary for darwin/arm64; DARWIN_COMPILE_EXCEPTIONS is the single exception list (today: internal/daemon -> #237, delete when its compile fix lands). Wired as a step in the mcpx test (push) and stress-pr (PR) jobs on the existing ubuntu runners; local command documented in pkgs/mcpx/AGENTS.md. Verified on laptop at c1b9052c5: gate passes in ~38s with the exception; with DARWIN_COMPILE_EXCEPTIONS emptied it fails naming internal/daemon (takeover_test.go:24 SOCK_CLOEXEC). Baseline re-verified fresh: darwin build passes, exactly one test package fails to compile. --- .github/workflows/mcpx.yml | 18 +++++++ pkgs/mcpx/AGENTS.md | 21 ++++++++ pkgs/mcpx/scripts/darwin-compile-check.sh | 60 +++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100755 pkgs/mcpx/scripts/darwin-compile-check.sh diff --git a/.github/workflows/mcpx.yml b/.github/workflows/mcpx.yml index 614df2bcea..7e57bde9cf 100644 --- a/.github/workflows/mcpx.yml +++ b/.github/workflows/mcpx.yml @@ -141,6 +141,15 @@ jobs: # every run and the module cache was rebuilt from scratch each time. cache-dependency-path: pkgs/mcpx/go.sum + # Darwin compile gate (#1988): cross-compile every mcpx test + # package for darwin/arm64 on this ubuntu job, so a Linux-only + # test constant cannot reach macOS undetected (#237's break). + # The single exception list lives in the script; it must be + # emptied as #237's compile fix lands. + - name: Darwin compile gate + working-directory: pkgs/mcpx + run: bash scripts/darwin-compile-check.sh + - name: Check go.mod and go.sum are tidy working-directory: pkgs/mcpx # dezren39/nix#436: this module drifted untidy once (wazero @@ -381,6 +390,15 @@ jobs: cache: true cache-dependency-path: pkgs/mcpx/go.sum + # Darwin compile gate (#1988): cross-compile every mcpx test + # package for darwin/arm64 on this ubuntu job, so a Linux-only + # test constant cannot reach macOS undetected (#237's break). + # The single exception list lives in the script; it must be + # emptied as #237's compile fix lands. + - name: Darwin compile gate + working-directory: pkgs/mcpx + run: bash scripts/darwin-compile-check.sh + - uses: denoland/setup-deno@22d081ff2d3a40755e97629de92e3bcbfa7cf2ed # v2.0.5 with: deno-version: v2.x diff --git a/pkgs/mcpx/AGENTS.md b/pkgs/mcpx/AGENTS.md index 6b4c9eaef1..f86261f7c4 100644 --- a/pkgs/mcpx/AGENTS.md +++ b/pkgs/mcpx/AGENTS.md @@ -118,3 +118,24 @@ shows which names have a value. - Do not parse human output; use `mcpx --json `. - Do not assume a tool name is a valid identifier: `fancy-name` becomes `fancy_name`. `mcpx types` shows the real function name. + +## Darwin compile check (contributors) + +CI compiles for Linux only, so a Linux-only symbol in a `_test.go` file +(e.g. `syscall.SOCK_CLOEXEC`, #237) is invisible until someone runs the +suite on a Mac. The darwin compile gate (#1988) cross-compiles every +test package for darwin/arm64 on the existing ubuntu jobs — no Mac and +no macOS runner needed. Run it locally from `pkgs/mcpx`: + + bash scripts/darwin-compile-check.sh + +By hand, the same check is: + + GOOS=darwin GOARCH=arm64 go build ./... + GOOS=darwin GOARCH=arm64 go test -c -o /dev/null # per package with test files + +The script's `DARWIN_COMPILE_EXCEPTIONS` variable is the single list of +packages allowed to fail this compile today (currently +`internal/daemon`, tracked by #237). Emptying that one line must make +the gate fail on the excepted package — that is how you know the gate +still detects the class. Delete an entry when its fix lands. diff --git a/pkgs/mcpx/scripts/darwin-compile-check.sh b/pkgs/mcpx/scripts/darwin-compile-check.sh new file mode 100755 index 0000000000..e84635e69b --- /dev/null +++ b/pkgs/mcpx/scripts/darwin-compile-check.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# darwin-compile-check.sh — cross-compile gate for darwin/arm64 (#1988). +# +# Nothing else in CI ever compiles mcpx's test packages for darwin, so a +# Linux-only constant in a _test.go file is invisible until someone runs +# the suite on a Mac. That is exactly #237's break. This check costs +# ~30s on the existing ubuntu job and needs no macOS runner: it builds +# the module for darwin/arm64 and compiles every package's test binary. +# +# It does NOT run the tests (that needs darwin hardware; #1988/#237) and +# it does NOT fix any darwin portability defect (#237 owns those). +set -euo pipefail +cd "$(dirname "$0")/.." + +# The single exception list. A package named here may fail the darwin +# test compile without failing this gate; every other package must +# compile. Empty this list (one line) when the last entry is fixed. +# github.com/dezren39/mcpx/internal/daemon — #237: takeover_test.go +# uses syscall.SOCK_CLOEXEC (undefined on darwin). DELETE this entry +# when #237's compile fix lands. +DARWIN_COMPILE_EXCEPTIONS="${DARWIN_COMPILE_EXCEPTIONS-github.com/dezren39/mcpx/internal/daemon}" + +export GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 + +echo "darwin/arm64: go build ./..." +go build ./... + +failed=() +skipped=() +start=$SECONDS +while IFS= read -r pkg; do + [ -n "$pkg" ] || continue + if go test -c -o /dev/null "$pkg" 2>"/tmp/darwin-compile-err.txt"; then + case " $DARWIN_COMPILE_EXCEPTIONS " in + *" $pkg "*) echo "note: $pkg now compiles for darwin — remove it from DARWIN_COMPILE_EXCEPTIONS" ;; + esac + else + case " $DARWIN_COMPILE_EXCEPTIONS " in + *" $pkg "*) + echo "known exception (see list in this script): $pkg" + sed 's/^/ /' "/tmp/darwin-compile-err.txt" | head -3 + skipped+=("$pkg") + ;; + *) + echo "FAIL darwin test compile: $pkg" + sed 's/^/ /' "/tmp/darwin-compile-err.txt" + failed+=("$pkg") + ;; + esac + fi +done < <(go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./...) + +echo "darwin test-compile scan took $((SECONDS - start))s; exceptions skipped: ${#skipped[@]}" +if [ "${#failed[@]}" -gt 0 ]; then + echo "darwin compile gate FAILED for ${#failed[@]} package(s):" + printf ' %s\n' "${failed[@]}" + echo "Fix the darwin compile, or — only with a tracking issue — add the package to DARWIN_COMPILE_EXCEPTIONS in scripts/darwin-compile-check.sh." + exit 1 +fi +echo "darwin compile gate passed"