//scripts:scripts_test and //scripts/check-versions:check-versions_test drop their host-tools/no-remote-exec/no-remote-cache tags and run on the rbe-west workers like every other target (the worker image ships bash, git, python3, jq, yq, curl, openssl, unzip and coreutils; a missing tool fails the test under Bazel rather than skipping it). Go comes in hermetically as the registered SDK; check-versions.sh's `go build` is stood in for by the Bazel-built checker. The tests that walked the source checkout now get it as data: tools/bazel/go_srcs.py keeps a managed `repo_files` filegroup in every package and aggregates them into //:repo_files (exactly the tracked files Bazel can see; make bazel-sync-check fails on a package without one). scripts_test and docsync_test take it instead of hand-listed filegroups, and every TEST_SRCDIR/IsBazel skip and go-test-only block in them is gone. The release formula under .bazelignore'd .beads/ comes in through a @beads_formulas local repository; npm-package/ and .claude/ are visible to Bazel again (only their node_modules/worktrees stay ignored), so the npm manifest release check and the AGENTS.md skill links run under Bazel too. TestZZStdioNotLeaked falls back to TestMain's pre-run streams instead of skipping in a shard without its baseline. tools/bazel/equivalence_allowlist.txt shrinks from 20 skip entries to the two cmd/bd tests of plain go test's own bd build fallback, which Bazel never takes; pr-preflight-platforms now runs them on Linux, macOS and Windows. The scripts-go-checks scripts-test and allowlisted legs, their scripts (scripts-go-test.sh, allowlisted-go-tests.sh, run_allowlisted_go_tests.py) and main.yml's --compile-only warm for them are removed. The vet leg stays (ga-96smfk.18). Refs: ga-96smfk.16 Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
98 lines
4.5 KiB
Go
98 lines
4.5 KiB
Go
package scripts_test
|
|
|
|
import (
|
|
"os/exec"
|
|
"regexp"
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
// shardCountPattern matches a rule block's ` shard_count = N,` line, the
|
|
// same pattern bazelProxiedShardCount (scripts/ci_workflow_test.go) inlines
|
|
// for its own single use; shared here since both embedded accessors below
|
|
// need it.
|
|
var shardCountPattern = regexp.MustCompile(`(?m)^ shard_count = (\d+),$`)
|
|
|
|
// bazelEmbeddedCmdShardCount returns cmd/bd:bd_embedded_test's own
|
|
// shard_count from cmd/bd/BUILD.bazel: the single source of truth for the
|
|
// Bazel-only bazel-embedded lane's cmd/bd shard split (slice F1), which no
|
|
// longer has to equal PR Risk's/main.yml's legacy "Test (Embedded Dolt Cmd
|
|
// N/20)" fork/push jobs' matrix size — mirrors bazelProxiedShardCount (F2;
|
|
// see that function's doc comment in scripts/ci_workflow_test.go for the
|
|
// shared rationale, not repeated here).
|
|
func bazelEmbeddedCmdShardCount(t *testing.T) int {
|
|
t.Helper()
|
|
root := sourceRepoRoot(t)
|
|
rule := bazelRuleBlock(readPolicyFile(t, root, "cmd/bd/BUILD.bazel"), "bd_embedded_test")
|
|
m := shardCountPattern.FindStringSubmatch(rule)
|
|
if m == nil {
|
|
t.Fatalf("cmd/bd:bd_embedded_test has no `shard_count = N,` in cmd/bd/BUILD.bazel:\n%s", rule)
|
|
}
|
|
n, err := strconv.Atoi(m[1])
|
|
if err != nil {
|
|
t.Fatalf("cmd/bd:bd_embedded_test shard_count: %v", err)
|
|
}
|
|
return n
|
|
}
|
|
|
|
// bazelEmbeddedStorageShardCount returns
|
|
// embeddeddolt:embeddeddolt_embedded_test's own shard_count from
|
|
// internal/storage/embeddeddolt/BUILD.bazel: the single source of truth for
|
|
// the Bazel-only bazel-embedded lane's storage shard split (slice F1), which
|
|
// no longer has to equal PR Risk's/main.yml's legacy "Test (Embedded Dolt
|
|
// Storage N/5)" fork/push jobs' matrix size. Mirrors
|
|
// bazelEmbeddedCmdShardCount above; see its doc comment.
|
|
func bazelEmbeddedStorageShardCount(t *testing.T) int {
|
|
t.Helper()
|
|
root := sourceRepoRoot(t)
|
|
rule := bazelRuleBlock(readPolicyFile(t, root, "internal/storage/embeddeddolt/BUILD.bazel"), "embeddeddolt_embedded_test")
|
|
m := shardCountPattern.FindStringSubmatch(rule)
|
|
if m == nil {
|
|
t.Fatalf("embeddeddolt:embeddeddolt_embedded_test has no `shard_count = N,` in internal/storage/embeddeddolt/BUILD.bazel:\n%s", rule)
|
|
}
|
|
n, err := strconv.Atoi(m[1])
|
|
if err != nil {
|
|
t.Fatalf("embeddeddolt:embeddeddolt_embedded_test shard_count: %v", err)
|
|
}
|
|
return n
|
|
}
|
|
|
|
// S3 (F1, mirroring F2's TestProxiedShardManifestGeneratorNotStale in
|
|
// scripts/pr_risk_bazel_coverage_test.go — see that test's doc comment for
|
|
// the full --check rationale, not repeated here): the Bazel-only 50-shard
|
|
// cmd block and 15-shard storage block are not frozen like their files'
|
|
// legacy 20- and 5-shard blocks. gen_embedded_{cmd,storage}_shard_manifest.py
|
|
// --check verifies only that the committed block names every discovered
|
|
// test exactly once, failing with the exact command to fix it when a name
|
|
// is missing, stale, or duplicated — run here so a drifted block fails `go
|
|
// test ./scripts/...` (and scripts-go-checks on fork PRs) instead of only
|
|
// surfacing as a test silently never running in any shard. The legacy
|
|
// blocks are deliberately excluded: both files document that their 20- and
|
|
// 5-shard blocks are frozen (see .github/scripts/embedded-{cmd,storage}-
|
|
// test-shards.txt and engdocs/TESTING.md), so a --check against them is
|
|
// expected to report "missing" entries by design (see those generators'
|
|
// module docstrings) and is not what this test runs.
|
|
func TestCmdEmbeddedShardManifestGeneratorNotStale(t *testing.T) {
|
|
python := requireHostTool(t, "python3")
|
|
root := sourceRepoRoot(t)
|
|
shards := strconv.Itoa(bazelEmbeddedCmdShardCount(t))
|
|
cmd := exec.Command(python, "scripts/ci/gen_embedded_cmd_shard_manifest.py", shards, "--weights=duration", "--check")
|
|
cmd.Dir = root
|
|
if out, err := cmd.CombinedOutput(); err != nil {
|
|
t.Errorf("gen_embedded_cmd_shard_manifest.py %s --weights=duration --check: %v\n%s", shards, err, out)
|
|
}
|
|
}
|
|
|
|
// TestStorageEmbeddedShardManifestGeneratorNotStale mirrors
|
|
// TestCmdEmbeddedShardManifestGeneratorNotStale above for the storage tier's
|
|
// Bazel-only 15-shard block; see that test's doc comment.
|
|
func TestStorageEmbeddedShardManifestGeneratorNotStale(t *testing.T) {
|
|
python := requireHostTool(t, "python3")
|
|
root := sourceRepoRoot(t)
|
|
shards := strconv.Itoa(bazelEmbeddedStorageShardCount(t))
|
|
cmd := exec.Command(python, "scripts/ci/gen_embedded_storage_shard_manifest.py", shards, "--weights=duration", "--check")
|
|
cmd.Dir = root
|
|
if out, err := cmd.CombinedOutput(); err != nil {
|
|
t.Errorf("gen_embedded_storage_shard_manifest.py %s --weights=duration --check: %v\n%s", shards, err, out)
|
|
}
|
|
}
|