beads/scripts/ci/package-mcp.sh
Julian Knutsen 785f10724a
ci: bigger runners for the slowest cached-run jobs (MCP gate 8 vCPU -n16, Bazel test 4 vCPU) (#7381)
* ci: bigger runners for the slowest CI legs (MCP gate, Bazel test, Windows preflight)

Runner-size A/B against merge group 37721729916 (3m49s):

- package-mcp: 4 -> 8 vCPU with pytest -n 16 (BEADS_MCP_PYTEST_WORKERS,
  mode remote only; forks/ubuntu-latest keep package-mcp.sh's default 8).
  pytest was 70s, dominated by CPU-bound per-test `bd init` setup. Local,
  pinned with taskset: -n 8 on 4 CPUs 112s; -n 16 on 8 CPUs 60/57/58s,
  228 passed / 5 skipped in all three runs.
- bazel-test: 2 -> 4 vCPU. `bazel test //... --config=ci` spent ~63 of
  81s in client-side loading/analysis (critical path 7.65s, every action
  a remote cache hit).
- pr-preflight-platforms Windows leg: 4 -> 8 vCPU. main.yml's test-windows
  saver stays on 4 vCPU: the cache keys name runner.os/runner.arch, never
  the label, and actions/cache's version covers only paths + compression,
  so the entries are not size-specific; the other Windows consumers keep
  their exact label. TestWindowsPreflightLegReachesSaverAcrossSizes pins it.

Runner labels live in the shared constants in
scripts/ci_blacksmith_runner_test.go; TestBlacksmithBazelRunnerSizes checks
every bazel.yml lane's runs-on and the MCP worker count per rbe mode with
evalGHExpr. Revert any bump that does not save at least 15s.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(pr): keep the Windows preflight leg on 4 vCPU (A/B: 8 vCPU queued 63s)

#7381's PR run put pr-preflight-platforms' Windows leg on
blacksmith-8vcpu-windows-2025. The cache restore from main.yml's 4 vCPU
test-windows saver hit, but the job waited 63s for an 8 vCPU Windows runner
and finished at 144s against the 129s baseline on 4 vCPU, so the leg goes
back to blacksmith-4vcpu-windows-2025. With saver and consumer on one label
again, TestWindowsPreflightLegReachesSaverAcrossSizes and the separate
preflight runner map have nothing left to pin and are dropped; the result
is recorded next to platformsMatrixRunners, in pr.yml and in
CI_REQUIRED_CHECK_TOPOLOGY.md.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 05:16:20 +00:00

83 lines
2 KiB
Bash
Executable file

#!/usr/bin/env bash
# MCP Python package gate.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
MCP_DIR="$REPO_ROOT/integrations/beads-mcp"
# shellcheck source=../../.buildflags
source "$REPO_ROOT/.buildflags"
# shellcheck source=lib/timing.sh
source "$REPO_ROOT/scripts/ci/lib/timing.sh"
tmpdir=""
cleanup() {
if [[ -n "$tmpdir" ]]; then
rm -rf "$tmpdir"
fi
}
trap cleanup EXIT
prepare_bd_binary() {
tmpdir="$(mktemp -d)"
local target="$tmpdir/bd"
if [[ -n "${BEADS_TEST_BD_BINARY:-}" ]]; then
cp "$BEADS_TEST_BD_BINARY" "$target"
else
go build -o "$target" ./cmd/bd
fi
chmod +x "$target"
export PATH="$tmpdir:$PATH"
bd version
}
mcp_uv_sync() {
cd "$MCP_DIR"
uv sync --all-groups --locked
}
mcp_ruff() {
cd "$MCP_DIR"
uv run ruff check src/beads_mcp tests
}
mcp_mypy() {
cd "$MCP_DIR"
uv run mypy src/beads_mcp
}
mcp_pytest() {
cd "$MCP_DIR"
# Explicit worker count, not "auto": CI runners' reported CPU count
# doesn't always match the cgroup quota, and -n 8 is pinned to measured
# timing (tools/f3, 2026-10) on both 2 vCPU (2.7x) and 4 vCPU (~3x)
# runners. bazel.yml's package-mcp sets BEADS_MCP_PYTEST_WORKERS=16 on
# its 8 vCPU Blacksmith runner (the suite is dominated by per-test
# `bd init` fixture setup, so two workers per CPU still pay off).
# pytest-xdist is a pinned dev dependency (pyproject.toml).
local workers="${BEADS_MCP_PYTEST_WORKERS:-8}"
if [[ ! "$workers" =~ ^[1-9][0-9]*$ ]]; then
echo "BEADS_MCP_PYTEST_WORKERS must be a positive integer, got '$workers'" >&2
return 2
fi
uv run pytest -n "$workers" --durations=50
}
mcp_build() {
cd "$MCP_DIR"
rm -rf dist
uv build
}
cd "$REPO_ROOT"
ci_time "prepare bd for MCP package" -- prepare_bd_binary
ci_time "mcp uv sync" -- mcp_uv_sync
ci_time "mcp ruff check" -- mcp_ruff
ci_time "mcp mypy" -- mcp_mypy
ci_time "mcp pytest" -- mcp_pytest
ci_time "mcp build" -- mcp_build