beads/BUILD.bazel
Julian Knutsen a4509deb2d
ci(bazel): nogo replaces go vet and golangci-lint (ga-96smfk.18) (#7341)
* ci(bazel): nogo replaces go vet and golangci-lint (ga-96smfk.18)

Lint and vet now run as nogo inside the Bazel build, so they gate wherever
the Bazel lanes execute (rbe-west), and the golangci-lint and go vet jobs
leave pr.yml and main.yml.

- //tools/nogo (own go.mod, joined to beads' for go_deps only through
  gazelle.go.work): go test's vet checks (cmd/go's defaultVetFlags, the set
  scripts/ci/go-test-vet.sh ran) plus the eight linters .golangci.yml
  enables, each a wrapper over the library version golangci-lint v2.10.1
  uses (depguard, errcheck, forbidigo, gosec, misspell, sloglint, unconvert,
  unparam).
- .golangci.yml stays the single lint policy: Bazel embeds it and
  tools/nogo/internal/golangci applies it as golangci-lint does (enabled
  set, settings, run.tests: false as library-unit-only analysis, lax
  generated-file detection, path/path-except/text exclusion rules), with
  strict decoding so an unimplemented key fails the build.
- gascity's rules_go //nolint-range patch and x/tools ctrlflow patch,
  byte-identical.
- Windows/darwin: cross-configured, not a golangci leg. The pure lane's
  release cross-compile (//tools/bazel:release_cross, every library and
  binary for all eight release platforms, cgo off) runs nogo on every
  compile, a superset of golangci-lint's windows and darwin legs.
  scripts/pr-lint (make ci-pr-lint, bd preflight) runs `bazel build
  --config=nogo //...` plus release_cross for windows_amd64,darwin_arm64.
  release_cross skips tools/nogo, a separate Go module `go build ./...`
  never compiled.
- pr.yml: scripts-go-checks (vet) and pr-lint-wrapper (x3) are gone, with
  their ci-gate entries; main.yml: pr-lint-wrapper (x6) and go-vet-cache.
  scripts/ci/go-test-vet.sh and install-golangci-lint.sh are deleted.
- pre-commit hook and .pre-commit-config.yaml run `make lint-changed
  LINT_CHANGED_SCOPE=staged` (nogo over the staged packages); Makefile adds
  lint, vet and lint-changed. pr-lint.sh no longer runs gofmt
  (//scripts/repochecks:fmt_test owns it; ga-96smfk.41).
- internal/testutil/integration: five gosec findings in integration-tagged
  library files golangci-lint never built, now linted by the integration
  lanes, carry reasoned //nolint directives.

Parity: with the exclusion rules removed, golangci-lint and nogo report the
same 3,916 findings natively and 3,859 each for windows and darwin (file,
line, linter, text); with .golangci.yml as committed both report none.

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

* ci(bazel): equivalence.py leaves nested Go modules' tests out of go test's set

tools/nogo is its own Go module, so `go test ./...` in the root never runs
its tests; Bazel's unit lane does. Its packages are neither expected nor
extra.

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-07 05:17:22 +00:00

413 lines
15 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/prlintmake:__pkg__",
"//tests/upgrade_smoke:__pkg__",
],
)
exports_files([
"go.mod",
"go.sum",
])
# The golangci-lint configuration nogo applies (//tools/nogo), and its test.
exports_files(
[".golangci.yml"],
visibility = [
"//tools/nogo:__pkg__",
"//tools/nogo/internal/golangci:__pkg__",
],
)
# 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",
"//tests/migration:repo_files",
"//tests/regression:repo_files",
"//tests/upgrade_smoke:repo_files",
"//third_party/cc_toolchain:repo_files",
"//third_party/patches:repo_files",
"//tools/bazel:repo_files",
"//tools/docsmint:repo_files",
"//tools/nogo:repo_files",
"//tools/nogo/analyzers/depguard:repo_files",
"//tools/nogo/analyzers/errcheck:repo_files",
"//tools/nogo/analyzers/forbidigo:repo_files",
"//tools/nogo/analyzers/gosec:repo_files",
"//tools/nogo/analyzers/misspell:repo_files",
"//tools/nogo/analyzers/sloglint:repo_files",
"//tools/nogo/analyzers/unconvert:repo_files",
"//tools/nogo/analyzers/unparam:repo_files",
"//tools/nogo/internal/analyzertest:repo_files",
"//tools/nogo/internal/golangci:repo_files",
"//tools/nogo/internal/position:repo_files",
],
visibility = [
"//scripts:__pkg__",
"//scripts/repochecks:__pkg__",
"//test/docsync:__pkg__",
],
)
# --- end repo_files ---