beads/scripts/ci/package-bazel-bd.sh
Julian Knutsen aaae7e6aff
ci: package gates start after rbe, MCP pytest -n 8, gate jobs on Blacksmith (F3) (#7126)
* ci(bazel): move package-mcp/package-npm gates into bazel.yml (F3)

Package gates now build bd via Bazel (no --config=ci) when the rbe job
enables it and fall back to go build otherwise, so forks/Dependabot/rbe-off
runs are unaffected. pr.yml's CI Gate keeps PACKAGE_MCP/PACKAGE_NPM required
and never-skippable, now sourced from needs.bazel.outputs.*; the retired
detect-package-gates/package-mcp/package-npm pr.yml jobs and
DETECT_PACKAGE_GATES are deleted. MCP pytest pins -n 8 explicitly with
pytest-xdist locked via uv lock. rbe, bazel-coverage, and both required gate
jobs move to Blacksmith for same-repo PRs (gate names unchanged).

Also closes a gap in detect-package-gates.sh (missing bazel.yml in the
force-both-gates path list, since the job definitions moved there) and wires
integrations/beads-mcp's manifest/lock into scripts_test's Bazel data so the
new pytest-xdist pin check runs under `bazel test` too.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): review fix-up for F3 package gates (SF-1, SF-2, nits)

Review of 65f378d241 (~/beads-bazel-plan/f3/review.md, no blockers) found:

- SF-1: the package gates' `bazel build //cmd/bd:bd_for_tests` resolved to
  a different output configuration (k8-fastbuild) than `bazel test
  --config=ci`'s bd_for_tests (k8-fastbuild-ST-..., via test:ci ->
  test:prcore's --@rules_go//go/config:race), so it got no action-cache
  reuse from the test job. Add the matching race flag to both jobs' build
  step; verified with cquery that both invocations now cquery to the
  identical bazel-out/k8-fastbuild-ST-.../bin/cmd/bd/bd_for_tests/bd path,
  and with a real build that it's an action-cache hit once bazel test
  --config=ci has run. Update the pinned Run string in
  pr_lanes_bazel_coverage_test.go and the impl report's cache-reuse claim.
- SF-2: drop stale comments/doc text saying the package gates download
  bazel-ci-build-artifacts; they build their own bd now (bazel.yml,
  pr.yml, engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md).

Nits: pin both required gates' display names in TestSameRepoBlacksmithRunners
(nothing else reads job.Name, so a rename would otherwise go uncaught); pin
the package jobs' Python/uv/Node setup against main.yml's copies; add
timeout-minutes to both gate jobs and detect-ci-tier (same-repo PRs now run
on paid Blacksmith minutes, not a free runner's 360-minute default); shut
down Bazel and remove the RBE client key right after each package job
packages its Bazel-built bd (nothing downstream needs either); add
scripts/ci/package-bazel-bd.sh to detect-package-gates.sh's both-gates
trigger arm and pin it in TestDetectPackageGatesCoversBazelWorkflow.

Every fix mutation-tested (mutate -> test fails with a specific message ->
restore from a /tmp backup, diff-confirmed identical -> test passes again).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-03 00:03:43 -07:00

42 lines
1.7 KiB
Bash
Executable file

#!/usr/bin/env bash
# Packages the Bazel-built bd in pr.yml's ci-build-artifacts layout
# (bd-linux-gms-pure, SHA256SUMS, build-manifest.txt) for bazel.yml.
#
# The binary is //cmd/bd:bd_for_tests, the non-race gms_pure_go cgo bd that
# Bazel's own tests exec (//cmd/bd:bd is race built under --config=ci); run
# after `bazel test //... --config=ci` (whose test:ci downloads it) or after
# `bazel build //cmd/bd:bd_for_tests` directly (bazel.yml's package gates:
# only test:ci is defined in .bazelrc, so `bazel build --config=ci` fails).
# Either way the same bd_for_tests output path is what this script packages.
# Unlike `go build`, it carries no vcs.* or CGO_ENABLED build settings, so
# `bd version` shows no commit and scripts/verify-cgo.sh would pass
# vacuously; no consumer of the artifact reads either.
#
# Usage: scripts/ci/package-bazel-bd.sh OUT_DIR
set -euo pipefail
out="${1:?usage: $0 OUT_DIR}"
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$repo_root"
# For BEADS_BUILD_TAGS (the manifest's build_tags, as in pr.yml).
# shellcheck source=/dev/null
source ./.buildflags
mapfile -t found < <(find -H bazel-out -path '*/bin/cmd/bd/bd_for_tests/bd' -type f)
if [ "${#found[@]}" -ne 1 ]; then
echo "::error::want exactly one //cmd/bd:bd_for_tests output, found ${#found[@]}: ${found[*]}"
exit 1
fi
mkdir -p "$out"
install -m 755 "${found[0]}" "$out/bd-linux-gms-pure"
cd "$out"
./bd-linux-gms-pure version
sha256sum bd-linux-gms-pure > SHA256SUMS
{
echo "commit=$(git -C "$repo_root" rev-parse HEAD)"
echo "go_version=$(go version bd-linux-gms-pure | sed 's/^[^:]*: //')"
echo "build_tags=${BEADS_BUILD_TAGS}"
echo "artifact=bd-linux-gms-pure"
echo "builder=bazel //cmd/bd:bd_for_tests"
} > build-manifest.txt