beads/BUILD.bazel
Julian Knutsen b1fe68e63a
ci(bazel): run pr.yml's repository guards as Bazel tests (#7329)
fast-checks, PR Policy, and the Linux leg of check-doc-freshness-platforms
ran repository guards on GitHub runners. They now run as Bazel tests in
bazel.yml's `test` lane (remote, cached), each over only the files it reads:

- tools/bazel/repo_subset.bzl picks a narrow, path-selected slice of
  //:repo_files at analysis time. scripts/repochecks/run_check.sh copies that
  slice into a throwaway git checkout and runs the unchanged guard there.
- //scripts/repochecks: build_tags, workflow_tags, go_install_guidance,
  winget_portable_alias, migration_hygiene (checks A and B),
  fmt (registered SDK gofmt), doc_freshness, workapi_frontend_boundary,
  types_gen_drift (`make api-check` drift, oapi-codegen from go.mod).
- //scripts:doc_freshness_required_test (integration lane, -required-suite)
  and //scripts/gitattributespolicy:gitattributespolicy_required_host_test
  cover the Linux doc-freshness leg.
- check-versions stays covered by //internal/versioncheck:versioncheck_test.
  check-testing-short stays covered by //scripts:scripts_test.

pr-policy-wrapper is deleted. fast-checks keeps only the two checks that
need the PR base: migration hygiene's delta half (MIGRATION_HYGIENE_SCOPE=
delta) and the .beads diff. check-doc-flags stays, because it builds bd from
the pinned release tag. The example Go modules leave .bazelignore so gofmt
and the grep guards see them. check_testcases.py now accepts --not-go
//pkg:all.

Refs: ga-96smfk.20

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 00:59:18 +00:00

389 lines
14 KiB
Python

load("@gazelle//:def.bzl", "gazelle")
load("@rules_go//go:def.bzl", "go_library", "go_test")
# gazelle:prefix github.com/steveyegge/beads
# gazelle drops files whose build constraints name a tag it does not know.
# integration is listed so the `//go:build integration` test files (and
# //internal/testutil/integration) are in srcs and deps; rules_go filters them
# out of every build except --config=integration (.bazelrc), which sets the tag.
# gazelle:build_tags gms_pure_go,integration
# integrations/ holds no Go; it stays visible to Bazel (not in .bazelignore)
# so //:repo_files covers it for //test/docsync's link checks and the
# repository-policy tests in //scripts.
# gazelle:exclude integrations
# The two example Go modules (own go.mod, built against a released beads) are
# not part of this build either, but they are tracked files the repository
# guards (gofmt, build-tag and install-guidance checks in
# //scripts/repochecks) must see, so they are not in .bazelignore.
# gazelle:exclude examples/library-usage
# gazelle:exclude examples/bd-example-extension-go
gazelle(name = "gazelle")
exports_files(
[".buildflags"],
visibility = [
"//scripts/pr-lint:__pkg__",
"//scripts/prlintmake:__pkg__",
],
)
exports_files([
"go.mod",
"go.sum",
])
# Repository files read by source-scanning tests, declared as their `data` so
# the tests run under `bazel test` and remote execution.
exports_files(
[".gitattributes"],
visibility = ["//scripts/gitattributespolicy:__pkg__"],
)
# //cmd/bd:bd_test: tracked git hooks (generator parity) and the formula
# primitive fixtures.
filegroup(
name = "bd_test_files",
srcs = glob([
".githooks/*",
"examples/formulas/primitives/**",
]),
visibility = ["//cmd/bd:__pkg__"],
)
exports_files(
[".claude-plugin/marketplace.json"],
visibility = ["//cmd/bd/setup:__pkg__"],
)
# PR Risk's manifest-sharded tiers' shard scripts and their committed
# manifests (embedded-Dolt cmd and storage, proxied-server cmd, server-Dolt
# storage). The variants (//cmd/bd:bd_embedded_test, //cmd/bd:bd_proxied_test,
# //internal/storage/embeddeddolt:embeddeddolt_embedded_test,
# //internal/storage/dolt:dolt_server_full_test) run them through
# tools/bazel/go_test_manifest_shard.sh, so each Bazel shard runs exactly the
# tests of the CI job with the same shard number.
exports_files(
[
".github/scripts/embedded-cmd-test-shards.txt",
".github/scripts/embedded-storage-test-shard.sh",
".github/scripts/embedded-storage-test-shards.txt",
".github/scripts/embedded-test-shard.sh",
".github/scripts/proxied-cmd-test-shards.txt",
".github/scripts/proxied-test-shard.sh",
".github/scripts/server-storage-test-shard.sh",
".github/scripts/server-storage-test-shards.txt",
],
visibility = [
"//cmd/bd:__pkg__",
"//internal/storage/dolt:__pkg__",
"//internal/storage/embeddeddolt:__pkg__",
],
)
# //internal/versioncheck and //scripts/check-versions release-gate tests: the
# metadata surfaces versioncheck.releaseSources gates, plus the canonical
# version it compares them against and the tracked git hooks whose version
# markers it checks.
#
# Hand-listed rather than globbed because releaseSources is itself a closed
# list: a newly gated surface must be added here too, and until it is the test
# fails under Bazel (it passes under `go test`, which sees the whole checkout).
filegroup(
name = "release_metadata_files",
srcs = [
".claude-plugin/marketplace.json",
"integrations/beads-mcp/pyproject.toml",
"integrations/beads-mcp/src/beads_mcp/__init__.py",
"integrations/beads-mcp/uv.lock",
"npm-package/package.json",
"//cmd/bd:version.go",
"//cmd/bd:winres/manifest.xml",
"//cmd/bd:winres/winres.json",
"//plugins/beads:.claude-plugin/plugin.json",
"//plugins/beads:.codex-plugin/plugin.json",
"//plugins/beads:.copilot-plugin/plugin.json",
] + glob([".githooks/*"]),
visibility = [
"//internal/versioncheck:__pkg__",
"//scripts/check-versions:__pkg__",
],
)
go_library(
name = "beads",
srcs = [
"beads.go",
"beads_cgo.go",
"beads_nocgo.go",
"claim.go",
],
importpath = "github.com/steveyegge/beads",
visibility = ["//visibility:public"],
deps = [
"//internal/beads",
"//internal/configfile",
"//internal/doltserver",
"//internal/storage",
"//internal/storage/backends",
"//internal/storage/dolt",
"//internal/storage/domain",
"//internal/storage/embeddeddolt",
"//internal/storage/schema",
"//internal/types",
"//internal/workspacegate",
],
)
go_test(
name = "beads_test",
srcs = [
"beads_gated_test.go",
"beads_test.go",
"claim_roundtrip_test.go",
"claim_test.go",
"errors_test.go",
"export_dependency_add_options_test.go",
"issue_lifecycle_external_test.go",
"issue_roles_external_test.go",
"open_backend_selection_test.go",
"open_nocgo_test.go",
"query_interfaces_cgo_test.go",
"query_interfaces_test.go",
],
embed = [":beads"],
deps = [
"//internal/hooks",
"//internal/storage",
"//internal/storage/backends",
"//internal/storage/dolt",
"//internal/storage/domain",
"//internal/storage/embeddeddolt",
"//internal/telemetry",
"//internal/testutil",
"//internal/types",
"//internal/workspacegate",
"//issueops",
],
)
# //internal/httpclient/encode:encode_test regenerates and compares the shipped
# divergence ledger doc (TestDivergenceLedgerDocMatchesLedger), so the doc must
# be readable as data under `bazel test`. docsync_files above globs it too, but
# that filegroup's visibility is scoped to //test/docsync alone.
exports_files(
["engdocs/design/http-divergence-ledger.md"],
visibility = ["//internal/httpclient/encode:__pkg__"],
)
# --- begin repo_files (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) ---
filegroup(
name = "repo_files",
srcs = glob(
["**"],
exclude = [
"**/*.db",
"**/*.exe",
"**/*.out",
"**/*.prof",
"**/*.pyc",
"**/*.test",
"**/__pycache__/**",
"**/node_modules/**",
".agents/**",
".amp/**",
".augment/**",
".bazelrc.local",
".claude/*.lock",
".claude/*.log",
".claude/settings.local.json",
".codex/**",
".cursor/**",
".direnv/**",
".envrc",
".git/**",
".idea/**",
".logs/**",
".vscode/**",
"bazel-*/**",
"bd",
"bd-fixed",
"bd-original",
"bd-test",
"bd_test",
"beads",
"go.work",
"go.work.sum",
"history/**",
"mcp_agent_mail/**",
"npm-package/bin/*.tar.gz",
"npm-package/bin/*.zip",
"npm-package/bin/CHANGELOG.md",
"npm-package/bin/LICENSE",
"npm-package/bin/README.md",
"npm-package/bin/bd",
"npm-package/package-lock.json",
"output",
"result",
"state.json",
"user.bazelrc",
],
) + [
"//backend:repo_files",
"//backend/conformance:repo_files",
"//beadserrors:repo_files",
"//cmd/bd:repo_files",
"//cmd/bd/doctor:repo_files",
"//cmd/bd/doctor/fix:repo_files",
"//cmd/bd/protocol:repo_files",
"//cmd/bd/setup:repo_files",
"//format:repo_files",
"//internal/ado:repo_files",
"//internal/atomicfile:repo_files",
"//internal/audit:repo_files",
"//internal/beads:repo_files",
"//internal/ceiling:repo_files",
"//internal/compact:repo_files",
"//internal/config:repo_files",
"//internal/configfile:repo_files",
"//internal/creds:repo_files",
"//internal/debug:repo_files",
"//internal/doltremote:repo_files",
"//internal/doltserver:repo_files",
"//internal/doltversion:repo_files",
"//internal/eventsjournal:repo_files",
"//internal/execenv:repo_files",
"//internal/fdhygiene:repo_files",
"//internal/formula:repo_files",
"//internal/formula/cmd/schemagen:repo_files",
"//internal/formula/schemagen:repo_files",
"//internal/git:repo_files",
"//internal/gitenv:repo_files",
"//internal/githooksenv:repo_files",
"//internal/github:repo_files",
"//internal/gitignore:repo_files",
"//internal/gitlab:repo_files",
"//internal/gittraceenv:repo_files",
"//internal/hooks:repo_files",
"//internal/httpapi:repo_files",
"//internal/httpapi/apigen:repo_files",
"//internal/httpapi/spec:repo_files",
"//internal/httpapi/wireshape:repo_files",
"//internal/httpapi/wireshape/cmd/gendigest:repo_files",
"//internal/httpclient:repo_files",
"//internal/httpclient/encode:repo_files",
"//internal/httpclient/wire:repo_files",
"//internal/idgen:repo_files",
"//internal/jira:repo_files",
"//internal/linear:repo_files",
"//internal/lockfile:repo_files",
"//internal/memoryapi:repo_files",
"//internal/metrics:repo_files",
"//internal/migration:repo_files",
"//internal/migration/legacysqlite:repo_files",
"//internal/molecules:repo_files",
"//internal/notion:repo_files",
"//internal/procid:repo_files",
"//internal/query:repo_files",
"//internal/recipes:repo_files",
"//internal/remotecache:repo_files",
"//internal/routing:repo_files",
"//internal/storage:repo_files",
"//internal/storage/backendnames:repo_files",
"//internal/storage/backends:repo_files",
"//internal/storage/batchbench:repo_files",
"//internal/storage/batchfixtures:repo_files",
"//internal/storage/contextinfo:repo_files",
"//internal/storage/createbatchequiv:repo_files",
"//internal/storage/dberrors:repo_files",
"//internal/storage/dbproxy/identity:repo_files",
"//internal/storage/dbproxy/pidfile:repo_files",
"//internal/storage/dbproxy/proxy:repo_files",
"//internal/storage/dbproxy/server:repo_files",
"//internal/storage/dbproxy/util:repo_files",
"//internal/storage/depid:repo_files",
"//internal/storage/dolt:repo_files",
"//internal/storage/doltutil:repo_files",
"//internal/storage/domain:repo_files",
"//internal/storage/domain/db:repo_files",
"//internal/storage/domain/fs:repo_files",
"//internal/storage/domain/git:repo_files",
"//internal/storage/embeddeddolt:repo_files",
"//internal/storage/embeddeddolt/cmd:repo_files",
"//internal/storage/externaldeps:repo_files",
"//internal/storage/fs:repo_files",
"//internal/storage/git:repo_files",
"//internal/storage/issueops:repo_files",
"//internal/storage/journalscan:repo_files",
"//internal/storage/kvkeys:repo_files",
"//internal/storage/memoryops:repo_files",
"//internal/storage/rowid:repo_files",
"//internal/storage/schema:repo_files",
"//internal/storage/sqlbuild:repo_files",
"//internal/storage/sqlclass:repo_files",
"//internal/storage/sqlcount:repo_files",
"//internal/storage/storagecontract:repo_files",
"//internal/storage/uow:repo_files",
"//internal/storage/versioncontrolops:repo_files",
"//internal/telemetry:repo_files",
"//internal/templates:repo_files",
"//internal/templates/agents:repo_files",
"//internal/testutil:repo_files",
"//internal/testutil/bazeltest:repo_files",
"//internal/testutil/credentialcmd:repo_files",
"//internal/testutil/fixtures:repo_files",
"//internal/testutil/integration:repo_files",
"//internal/timeparsing:repo_files",
"//internal/tracker:repo_files",
"//internal/tracker/conformance:repo_files",
"//internal/types:repo_files",
"//internal/ui:repo_files",
"//internal/uimd:repo_files",
"//internal/utils:repo_files",
"//internal/validation:repo_files",
"//internal/versioncheck:repo_files",
"//internal/workapi:repo_files",
"//internal/workapi/storecounter:repo_files",
"//internal/workapi/storequerier:repo_files",
"//internal/workapi/storereader:repo_files",
"//internal/workapi/storereadycounter:repo_files",
"//internal/workapi/storestats:repo_files",
"//internal/workapi/storeversionreconciler:repo_files",
"//internal/workapi/storeworkspaceconfig:repo_files",
"//internal/workspacegate:repo_files",
"//internal/worktreeremove:repo_files",
"//issueops:repo_files",
"//journalops:repo_files",
"//memoryops:repo_files",
"//platforms:repo_files",
"//plugins/beads:repo_files",
"//schema:repo_files",
"//scripts:repo_files",
"//scripts/bench-ready-indexes:repo_files",
"//scripts/check-versions:repo_files",
"//scripts/checkworkflowtags:repo_files",
"//scripts/gitattributespolicy:repo_files",
"//scripts/internal/testbash:repo_files",
"//scripts/migration-test/catalog:repo_files",
"//scripts/pr-lint:repo_files",
"//scripts/prlintmake:repo_files",
"//scripts/repochecks:repo_files",
"//scripts/repro-dolt-hang:repo_files",
"//scripts/repro-dolt-prod-timeouts:repo_files",
"//scripts/workflowtags:repo_files",
"//test/conformance:repo_files",
"//test/docsync:repo_files",
"//test/testmainconvention:repo_files",
"//third_party/cc_toolchain:repo_files",
"//third_party/patches:repo_files",
"//tools/bazel:repo_files",
"//tools/docsmint:repo_files",
],
visibility = [
"//scripts:__pkg__",
"//scripts/repochecks:__pkg__",
"//test/docsync:__pkg__",
],
)
# --- end repo_files ---