Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/mcpx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions pkgs/mcpx/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,24 @@ shows which names have a value.
- Do not parse human output; use `mcpx --json <command>`.
- 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 <package> # 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.
60 changes: 60 additions & 0 deletions pkgs/mcpx/scripts/darwin-compile-check.sh
Original file line number Diff line number Diff line change
@@ -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"
Loading