Commit graph

5 commits

Author SHA1 Message Date
Julian Knutsen
66075be43a
ci(bazel): Bazel 9.3.0 (prerequisite for the remote repo contents cache) (#7439)
.bazelversion 9.2.0 -> 9.3.0. setup-bazel pins the 9.3.0 release
sha256s (bazel-9.3.0-linux-{x86_64,arm64}.sha256) next to 9.2.0's,
so the composite stays a valid byte copy for gascity until it bumps
too. MODULE.bazel.lock refreshed: 9.3.0's bundled module graph
resolves apple_support 2.5.2 and rules_cc 0.2.15 and changes four
extension bzlTransitiveDigests.

9.3.0 fixes bazel#30905 (the remote repo contents cache overlay
serialized getInputStream), the hard prerequisite for ga-vnycm2.25.

Refs ga-vnycm2.23

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 21:03:41 +00:00
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
Julian Knutsen
cb0dcbecf2
ci(bazel): hermetic LLVM C toolchain and pinned rbe_worker exec platform (#7325)
beads' MODULE.bazel registered no C toolchain, so -race and cgo builds used
the autodetected local_config_cc of the machine that ran analysis. From a
client with lld installed (cherry) every remote cgo/-race link failed with
"collect2: fatal error: cannot find 'ld'" (the workers have no lld), and the
host gcc path, lld availability and gcc-version inputs keyed every Go action
to the client machine.

Port gastownhall/gascity's design:
- toolchains_llvm 1.11.0 with a pinned LLVM 22.1.8 slice
  (third_party/cc_toolchain/llvm_dist.bzl) and a sysroot of sha256-pinned
  Ubuntu 24.04 debs (deb_sysroot.bzl), without ICU (ICU policy);
  stock toolchains_llvm LLVM on other hosts.
- .bazelrc: BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 so nothing falls back to the
  host compiler.
- //platforms:rbe_worker, selected unconditionally, whose worker-env exec
  property is the sha256 of tools/rbe/worker-env.txt (a copy of the shared
  rbe-west OSS pool's manifest, owned by gascity), so the worker host is in
  every action key.
- scripts/bazel_hermetic_cc_test.go and scripts/rbe_worker_env_test.go guard
  both.

Refs: ga-96smfk.20

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 00:59:11 +00:00
Julian Knutsen
4f2f8f2b79
test(bazel): hermetic test env + inject bd binary into subprocess tests (#6843)
* test(bazel): isolate the bazel test environment like pr-core's go test

Every `bazel test` process now runs under //tools/bazel:test_env (wired with
`test --run_under`), a wrapper that mirrors scripts/ci/lib/test-env.sh: a
private HOME/USERPROFILE, XDG_CONFIG_HOME, DOLT_ROOT_PATH and empty
GIT_CONFIG_GLOBAL, GIT_CONFIG_NOSYSTEM, BEADS_TEST_IGNORE_REPO_CONFIG, and
the same scrub of workspace/Dolt-server variables. Everything lives in one
fresh mktemp directory under /tmp that is removed when the test exits, so
TMPDIR (t.TempDir) stays short enough for unix sockets and is never shared
between concurrent runs.

This replaces `--test_env=HOME` (the client's HOME string entered the action
key and was shipped to remote workers, where it does not exist: the
embeddeddolt suite panicked on "stat /home/ubuntu") and the shared
`--test_tmpdir=/tmp/bbt`. No host path or client env enters the action key.

bd_test (~10 min under -race -short) and embeddeddolt_test (~6 min) get
size = "large" / timeout = "long" instead of Bazel's 300 s default; pr-core
gives go test -timeout=30m. rules_shell (already in the module graph) becomes
a direct dep for sh_binary. MODULE.bazel.lock records the pybind11 extension
that building these test targets evaluates, so `make bazel-sync` is stable.

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

* test(bazel): inject the bd binary into subprocess tests (slice B3)

Tests that exec bd used to `go build` it themselves, which cannot work under
`bazel test` (no Go toolchain or module tree in the sandbox or on a remote
worker): 135 cmd/bd subtests failed with "go build failed", and protocol,
doctor and uow failed the same way.

- //cmd/bd:bd_for_tests: a go_binary named bd, race = "off" (the non-race
  gms_pure_go binary these tests build today, even under --config=prcore).
- bd_test, protocol_test, doctor_test and uow_test declare it as data and set
  BEADS_TEST_BD_BINARY to its $(rlocationpath).
- bazeltest.PrebuiltBD is the one resolver: under Bazel it resolves the
  rlocationpath through runfiles (via the new bazeltest.RunfileEnv) and
  requires it; under plain go test it keeps today's semantics (absolute form
  of BEADS_TEST_BD_BINARY, or "" so the caller builds bd).
- cmd/bd's findPrebuiltBDBinary delegates to it, and the sites that read the
  variable by hand (init_embedded, shared_server_integration, cli_fast,
  migrate front door) now go through findPrebuiltBDBinary; uow calls it
  directly.
- Raw `go build` sites that never honored the variable (protocol, doctor
  dolt_e2e, test/conformance e2e, internal/beads integration TestMain) use
  it only under Bazel, so go test is unchanged; protocol and doctor fail
  instead of skipping when the injection is miswired. tests/regression is
  left alone (it builds candidate and baseline binaries on purpose).
- The read-only canary still forces a source build under go test; under
  Bazel the injected binary is already built from this tree.

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

* test(bazel): declare what cmd/bd and doctor tests read under bazel

With bd injected, the remaining //cmd/bd:bd_test and //cmd/bd/doctor failures
under `bazel test` were inputs the tests read from the checkout without
declaring them (they were hidden behind the go-build failures before):

- source-scanning guards (capability registry, events-journal construction,
  serve database source) parse cmd/bd, cmd/bd/doctor, cmd/bd/doctor/fix and
  internal/storage/embeddeddolt/cmd: those packages get go_srcs filegroups
  (tools/bazel/go_srcs.py) declared as data; serve_test resolves its package
  dir with bazeltest.CallerDir.
- .githooks (managed-section parity) and examples/formulas/primitives are
  declared through //:bd_test_files.
- the gofmt preflight tests exec gofmt: under Bazel they use the Go SDK's,
  declared as data and named by BEADS_TEST_GOFMT (bazeltest.RunfileEnv).
- TestGOMODCACHENotUnderTestHome guards in-test `go build`, which does not
  happen under Bazel, so it skips there.
- doctor's TestCheckDeletionsManifest_LegacyFile only passed because the
  process cwd happened to be inside a git checkout; its fixture is now a git
  repo and the check runs in it.

go test behavior is unchanged except that the deletions-manifest test no
longer depends on the caller's cwd.

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

* fix(bazel): give test_env a dolt identity; never fail on cleanup

beads_test_env_enter sets a dolt user.name/user.email in the fresh
DOLT_ROOT_PATH; test_env.sh created it empty, so tests that shell out to
dolt (remotecache, storage/dolt) failed with 'Author identity unknown'.
Write config_global.json directly (no dolt exec per test).

Also keep rm -rf in the EXIT trap from overriding the test's exit status
when a leftover child is still writing to the tmp root.

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

* build(bazel): re-sync BUILD files with main

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-09-27 11:38:03 -07:00
Julian Knutsen
57ef364501
build(bazel): side-by-side Bazel scaffold + policy tests (#6798)
* build(bazel): add side-by-side Bazel scaffold (module + gazelle)

Add a Bzlmod Bazel build alongside the Go toolchain. `go build` and
`go test` are unchanged; nothing in CI invokes Bazel yet.

- MODULE.bazel: rules_go 0.63.0, gazelle 0.53.0, Go SDK 1.26.7 (matches
  the go.mod toolchain directive), go_deps from go.mod.
- ICU policy (engdocs/ICU-POLICY.md): a go-mysql-server gazelle_override
  selects the pure-Go regex backend and excludes regex_cgo.go, and
  .bazelrc builds with --@rules_go//go/config:tags=gms_pure_go, so no
  target depends on go-icu-regex or links libicu.
- third_party/patches: three module_override patches for dolt deps that
  ship WORKSPACE-era BUILD files, adapted from the gascity project.
- .bazelrc: prcore/ci test configs (inert for now; they match pr-core's
  test selection, not yet its environment isolation) and a generic
  remote-exec config with a bounded remote timeout. Executor endpoints and
  TLS credentials come only from a gitignored .bazelrc.local/user.bazelrc
  or a CI rc outside the workspace.
- .bazelversion pins Bazel 9.2.0; .bazelignore skips separate modules,
  non-Go trees, nested agent worktrees (.claude, .worktrees) and local
  data/output dirs (.beads, .dolt, dist, .runtime, tmp), so a primary
  checkout neither builds nor gazelle-rewrites nested worktree copies.
- Gazelle-generated BUILD.bazel files for every Go package.
- Makefile: `make bazel-sync` (gazelle + bazel mod tidy).
- .gitignore: bazel-* output symlinks and machine-local rc files.

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

* test(bazel): policy tests for the Bazel configuration

Add scripts/bazel_policy_test.go, plain Go tests that run under both
`go test ./scripts` and `bazel test //scripts:scripts_test`:

- MODULE.bazel go_sdk.download version equals the go.mod toolchain.
- ICU policy: .bazelrc sets gms_pure_go for build, the go-mysql-server
  gazelle_override excludes regex_cgo.go, and the root BUILD.bazel
  carries `# gazelle:build_tags gms_pure_go`.
- .bazelversion pins an exact Bazel release.
- .bazelrc.local and user.bazelrc are gitignored (parsed from .gitignore
  and cross-checked with git check-ignore when in a checkout).
- No remote-execution endpoints or credentials in committed bazelrc-like
  files, Markdown docs or .github/**: remote/BES/TLS flags
  (--remote_executor, --remote_cache, --bes_backend, --remote_header,
  --tls_client_certificate, ...) with a literal value, with or without a
  URL scheme, and non-loopback gRPC URLs in rc/.github files. Placeholders,
  $VARIABLES, and loopback are allowed; Markdown gRPC URLs (OTel exporter
  docs) are not flagged. Skipped outside a git checkout, e.g. in the Bazel
  sandbox.

Each check is a pure function also exercised against fixtures that break
the invariant. The files the tests read are declared as data via
//:bazel_policy_files so they resolve from runfiles under Bazel.

scripts/check-build-tags.sh now treats Bazel invocations as governed by
.bazelrc: the shell command segment that invokes Bazel (split on &&, ||,
;, |, $( and backticks) is exempt from the per-line `go` tag check, while
a bare `go` in another segment of the same line is still flagged. When
any scanned file invokes Bazel (or .bazelrc exists) .bazelrc must set
--@rules_go//go/config:tags=gms_pure_go for build.
scripts/check_build_tags_test.go covers both in a temp repository.

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

* fix(scripts): split bazel lines in pure bash so check-build-tags works with BSD sed

BSD sed (macOS) does not expand \n in s/// replacements, so the segment
split never happened and the Bazel-exemption tests failed on macos-latest.

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

* test(scripts): skip check-build-tags tests when bash lacks mapfile

macOS runners use /bin/bash 3.2, which has no mapfile; check-build-tags.sh
has always required bash >= 4, so the new tests are skipped there.

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-09-27 03:41:02 -07:00