* fix(bazel): remove host-go dep from compact GC test; drop frozen shard blocks Replace the ungated `go build` in compact_gc_target_test.go's dolt-stand-in fixture with a Bazel-built go_binary (cmd/bd:compact_gc_fixture) wired via rlocationpath env + data, mirroring the existing preflight_go_fixture pattern. Falls back to `go build` only when not running under Bazel (bazeltest.IsBazel()). Also gate test_repo_beads_guard_test.go's `go env GOCACHE`/`GOMODCACHE` probes on !bazeltest.IsBazel(), since they previously ran unconditionally in every cmd/bd TestMain. Separately, delete the legacy 20-shard embedded-cmd and 15-shard proxied-cmd "frozen" manifest blocks in .github/scripts/*-test-shards.txt: their only consumers were pr-risk.yml fork/push jobs that have since migrated to bazel.yml. Update gen_embedded_cmd_shard_manifest.py and gen_proxied_shard_manifest.py to drop the frozen-block rendering/guard logic and default to the live Bazel-only shard counts (100 and 34), and refresh stale comments/docs (cmd/bd/BUILD.bazel, scripts/shard_manifest_test.go, engdocs/TESTING.md, engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md) that still described the deleted blocks. Verified no other BUILD/.github/scripts references read them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * build(bazel): auto-sync BUILD files Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/38069936930 (`make bazel-sync`: gazelle, tools/bazel/go_srcs.py, bazel mod tidy). Only BUILD.bazel, MODULE.bazel and MODULE.bazel.lock are ever pushed; see scripts/bazel-autofix-push.sh. * fix(bazel): gate remaining host-go calls; fix shard-manifest --weights footgun Address PR #7478 review findings (bee-ghosttrack): - scripts/ci/lib/test-env.sh: skip the GOCACHE/GOMODCACHE `go env` probes when TEST_SRCDIR is set, so scripts/test.sh's beads_test_env_enter never shells out to a bare `go` when reached from a Bazel-run go_test (e.g. //scripts:shell_scripts_test's TestTestScriptPrebuiltTestBinaryContract), where a farm masks host go/dolt to exit 127. Nothing on that path needs a cache directory. - scripts/ci/fmt-check.sh: describe_gofmt() no longer calls a PATH `go` under Bazel. It now resolves BEADS_TEST_GO (the hermetic SDK go already wired into scripts/prlintmake:prlintmake_test's env) via TEST_SRCDIR, and skips the version-reporting arm entirely when that isn't set (e.g. scripts/repochecks:fmt_test), rather than ever touching a possibly-masked PATH `go`. - Verified with a PATH stub (go/dolt scripts that log and exit 127) via `bazel --nohome_rc test --config=prcore //scripts/... //cmd/bd:bd_test --test_env=PATH=<stubdir>:/usr/bin:/bin:/usr/local/bin`: 26/26 targets pass, zero stub invocations logged. - gen_proxied_shard_manifest.py / gen_embedded_cmd_shard_manifest.py: default --weights to duration now that the manifests' only remaining blocks are duration-packed (the legacy inits-packed blocks were deleted alongside the PR Risk fork/push jobs that read them). Previously the bare `--write` default (inits) silently clobbered the live block's duration header and repacked with the wrong cost model; --check couldn't see it. Added TestProxiedShardManifestBareWriteIsIdempotent and TestEmbeddedCmdShardManifestBareWriteIsIdempotent to pin a bare --write as a no-op against the committed files. - cmd/bd/compact_gc_target_test.go: resolve the non-Bazel fallback fixture path from this file's own directory (runtime.Caller) instead of the test binary's working directory. - Refresh stale comments in .github/workflows/bazel.yml, scripts/shard_manifest_test.go, scripts/pr_risk_bazel_coverage_test.go, and scripts/embedded_shard_count_test.go that still described the deleted legacy 20/15-shard blocks and their retired fork/push jobs in the present tense. - Confirmed cmd/bd/BUILD.bazel's compact_gc_fixture go_binary (implicit pure/race defaults) still passes TestRunCompactDoltTargetsOnlyAuthorizedActiveDatabase under `bazel test //cmd/bd:bd_test`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
108 lines
3.3 KiB
Bash
108 lines
3.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Shared hermetic environment setup for broad local/CI test wrappers.
|
|
|
|
if [[ -n "${BEADS_CI_TEST_ENV_SH_LOADED:-}" ]]; then
|
|
return 0
|
|
fi
|
|
BEADS_CI_TEST_ENV_SH_LOADED=1
|
|
|
|
beads_test_env_enter() {
|
|
if [[ "${BEADS_TEST_ENV_DISABLE:-0}" == "1" ]]; then
|
|
return 0
|
|
fi
|
|
if [[ "${BEADS_TEST_ENV_ACTIVE:-0}" == "1" ]]; then
|
|
return 0
|
|
fi
|
|
|
|
local root
|
|
root="$(mktemp -d "${TMPDIR:-/tmp}/beads-test-env-XXXXXX")"
|
|
export BEADS_TEST_ENV_ROOT="$root"
|
|
export BEADS_TEST_ENV_ACTIVE=1
|
|
|
|
# Under `bazel test` (TEST_SRCDIR set) a bare `go` on PATH can be the
|
|
# farm's exit-127 mask for the host toolchain, and nothing downstream of
|
|
# this wrapper in that mode builds Go code or needs a cache directory
|
|
# (scripts/test.sh's prebuilt-test-binary path runs a binary Bazel already
|
|
# built), so skip the probe entirely rather than risk invoking it.
|
|
if [[ -z "${TEST_SRCDIR:-}" ]]; then
|
|
if [[ -z "${GOCACHE:-}" ]]; then
|
|
local go_cache
|
|
go_cache="$(go env GOCACHE 2>/dev/null || true)"
|
|
if [[ -n "$go_cache" ]]; then
|
|
export GOCACHE="$go_cache"
|
|
fi
|
|
fi
|
|
if [[ -z "${GOMODCACHE:-}" ]]; then
|
|
local go_mod_cache
|
|
go_mod_cache="$(go env GOMODCACHE 2>/dev/null || true)"
|
|
if [[ -n "$go_mod_cache" ]]; then
|
|
export GOMODCACHE="$go_mod_cache"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
mkdir -p "$root/home" "$root/xdg-config" "$root/dolt-root"
|
|
: >"$root/gitconfig"
|
|
|
|
export HOME="$root/home"
|
|
export USERPROFILE="$root/home"
|
|
export XDG_CONFIG_HOME="$root/xdg-config"
|
|
export DOLT_ROOT_PATH="$root/dolt-root"
|
|
export GIT_CONFIG_NOSYSTEM=1
|
|
export GIT_CONFIG_GLOBAL="$root/gitconfig"
|
|
export BEADS_TEST_IGNORE_REPO_CONFIG=1
|
|
if [[ "${BEADS_TEST_ENV_RUN_DOLT:-0}" != "1" ]]; then
|
|
beads_test_env_add_skip "dolt"
|
|
fi
|
|
|
|
unset BEADS_DIR
|
|
unset BEADS_DB
|
|
unset BD_DB
|
|
unset BD_JSON
|
|
unset BD_NO_DB
|
|
unset BD_NO_DAEMON
|
|
unset BD_ACTOR
|
|
unset BEADS_ACTOR
|
|
unset GT_ROOT
|
|
unset BEADS_DOLT_SHARED_SERVER
|
|
unset BEADS_DOLT_SERVER_MODE
|
|
unset BEADS_DOLT_AUTO_START
|
|
unset BEADS_DOLT_SERVER_HOST
|
|
unset BEADS_DOLT_SERVER_PORT
|
|
unset BEADS_DOLT_PORT
|
|
unset BEADS_DOLT_SERVER_DATABASE
|
|
unset BEADS_DOLT_SERVER_SOCKET
|
|
unset BEADS_DOLT_PASSWORD
|
|
# bazeltest debug override: never let an exported value point source-scan
|
|
# guards at another checkout.
|
|
unset BEADS_TEST_REPO_ROOT
|
|
|
|
if command -v dolt >/dev/null 2>&1; then
|
|
dolt config --global --add user.name "beads-test" >/dev/null 2>&1 || true
|
|
dolt config --global --add user.email "test@beads.local" >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
trap beads_test_env_cleanup EXIT
|
|
}
|
|
|
|
beads_test_env_add_skip() {
|
|
local service="$1"
|
|
local current=",${BEADS_TEST_SKIP:-},"
|
|
if [[ "$current" != *",$service,"* ]]; then
|
|
if [[ -n "${BEADS_TEST_SKIP:-}" ]]; then
|
|
export BEADS_TEST_SKIP="${BEADS_TEST_SKIP},${service}"
|
|
else
|
|
export BEADS_TEST_SKIP="$service"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
beads_test_env_cleanup() {
|
|
if [[ "${BEADS_TEST_ENV_KEEP:-0}" == "1" ]]; then
|
|
return 0
|
|
fi
|
|
if [[ -n "${BEADS_TEST_ENV_ROOT:-}" ]]; then
|
|
rm -rf "$BEADS_TEST_ENV_ROOT"
|
|
unset BEADS_TEST_ENV_ROOT
|
|
fi
|
|
}
|