beads/cmd/bd/protocol/BUILD.bazel
Julian Knutsen d90823480a
ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414)
* ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files

//scripts:scripts_test declared //:repo_files (the whole checkout), so every
PR re-ran it, and it took ~181s on rbe-west. Most of that (60-79s) was
TestBazelGatedLanesNeverRetryFlakyTests line-regexping the --run_under
wrapper's pinned dolt binary (tools/bazel/hermetic_bin/dolt, in every
test's runfiles); it now skips binary files, as git grep -I does.

tools/bazel/go_srcs.py's per-package repo_files block now partitions each
package's files into repo_go_srcs, repo_go_test_srcs, repo_doc_files and
repo_other_files, aggregated at the root; //:repo_files is their union
(same 4679 files). The //scripts tests are split into go_test targets by
what they read (traced per test with strace over a runfiles-shaped tree):

  scripts_test          CI/Bazel policy: //:repo_other_files (+1 Go file)
  shell_scripts_test    script fixtures: //scripts files, a few root files
  go_test_sources_test  _test.go scans: //:repo_go_test_srcs + shard files
  go_sources_test       check-testing-short.sh: every .go file
  tracked_files_test    every tracked file: //:repo_files

Shared helpers move to helpers-only files; TestScriptsTestTargetsPartition-
TheTests fails on a test file in no target or in two. //test/docsync and
the //scripts/repochecks slices declare partitions or single files instead
of //:repo_files where they can.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): skip only the non-checkout hermetic_bin dir in the flaky-retry walk

Skipping every binary file also stopped scanning tracked binaries (images,
.binpb fixtures). Skip just tools/bazel/hermetic_bin, the --run_under
wrapper's runfiles directory, which is not in the checkout, so the walk's
coverage of tracked files is unchanged.

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-09 05:13:07 +00:00

168 lines
5 KiB
Python

load("@rules_go//go:def.bzl", "go_library", "go_test")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("//tools/bazel:race.bzl", "go_test_race_off")
go_library(
name = "protocol",
srcs = ["corpus.go"],
importpath = "github.com/steveyegge/beads/cmd/bd/protocol",
visibility = ["//visibility:public"],
)
go_test(
name = "protocol_test",
srcs = [
"assignee_test.go",
"blocked_status_test.go",
"blocked_test.go",
"blocking_semantics_test.go",
"canonicalize_test.go",
"child_id_test.go",
"children_test.go",
"close_guard_test.go",
"comments_test.go",
"corpus_test.go",
"defer_test.go",
"dep_identity_test.go",
"errors_contract_test.go",
"exit_codes_init_test.go",
"exit_codes_test.go",
"helpers_test.go",
"input_validation_test.go",
"interchange_test.go",
"json_contract_test.go",
"lease_claim_test.go",
"lifecycle_test.go",
"memory_contract_test.go",
"preservation_test.go",
"ready_front_test.go",
"roundtrip_test.go",
"stale_test.go",
"status_validation_test.go",
"versioning_contract_test.go",
"wp4_helpers_test.go",
],
data = glob(["testdata/**"]) + ["//cmd/bd:bd_for_tests"],
embed = [":protocol"],
env = {"BEADS_TEST_BD_BINARY": "$(rlocationpath //cmd/bd:bd_for_tests)"},
deps = [
"//internal/storage/schema",
"//internal/testutil",
"//internal/testutil/bazeltest",
"@com_github_creack_pty//:pty",
],
)
# protocol_test without the race detector, which --config=doltserver
# otherwise turns on for every target: the contract corpus has always run
# `go test ./cmd/bd/protocol` without -race (PR Core covers the race build).
# Matching it is cheap: tools/bazel/race.bzl lands protocol_test's deps in
# the configuration the non-race //cmd/bd:bd_for_tests already builds them in,
# so the extra work is protocol_test's test-only libraries and one link.
# Racing it instead would also be acceptable (a race-only failure is a real
# bug); then drop this target and point protocol_dolt_test back at
# :protocol_test.
#
# Tags:
# manual: only protocol_dolt_test's input, never a build target of its
# own. `bazel test //...` in every lane still builds it through
# protocol_dolt_test (a test tag filter does not stop the build).
go_test_race_off(
name = "protocol_race_off",
tags = ["manual"],
test = ":protocol_test",
)
# protocol_test as the retired "Contract corpus" job ran it (non-race, like
# the job; see protocol_race_off), on the dolt-server lane: TestMain's server is a
# local `dolt sql-server` child of the test process, and
# BEADS_PROTOCOL_REQUIRE_DOLT=1 turns a server that cannot start into a
# failure, so the golden and double-run determinism tests cannot skip. It
# repeats protocol_test's `env`.
#
# Tags:
# dolt-server: starts hermetic dolt sql-servers from the pinned dolt in the
# test wrapper's runfiles (BEADS_TEST_DOLT_SERVER=local); excluded from
# --config=prcore/ci, selected by --config=doltserver. Runs remotely: no
# docker, and a missing server fails (REQUIRE=1) instead of skipping, so
# a cached pass is as good as a fresh one.
sh_test(
name = "protocol_dolt_test",
size = "large",
srcs = ["//tools/bazel:go_test_variant.sh"],
args = ["$(rootpath :protocol_race_off)"],
data = [
":protocol_race_off",
"//cmd/bd:bd_for_tests",
],
env = {
"BEADS_PROTOCOL_REQUIRE_DOLT": "1",
"BEADS_TEST_BD_BINARY": "$(rlocationpath //cmd/bd:bd_for_tests)",
"BEADS_TEST_DOLT_SERVER": "local",
"BEADS_TEST_REQUIRE_DOLT_CONTAINER": "1",
"GOMAXPROCS": "4",
},
shard_count = 8,
tags = ["dolt-server"],
)
# --- begin repo_files (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) ---
filegroup(
name = "repo_doc_files",
srcs = glob(
[
"**/*.md",
"**/*.mdx",
],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_srcs",
srcs = glob(
["**/*.go"],
allow_empty = True,
exclude = [
"**/*_test.go",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_go_test_srcs",
srcs = glob(
["**/*_test.go"],
allow_empty = True,
exclude = ["**/node_modules/**"],
),
visibility = ["//:__subpackages__"],
)
filegroup(
name = "repo_other_files",
srcs = glob(
["**"],
exclude = [
"**/*.db",
"**/*.exe",
"**/*.go",
"**/*.md",
"**/*.mdx",
"**/*.out",
"**/*.prof",
"**/*.pyc",
"**/*.test",
"**/__pycache__/**",
"**/node_modules/**",
],
),
visibility = ["//:__subpackages__"],
)
# --- end repo_files ---