manifest/bazel: workspace-root walker for nested workspaces#1341
Closed
Simon (simonhj) wants to merge 1 commit into
Closed
manifest/bazel: workspace-root walker for nested workspaces#1341Simon (simonhj) wants to merge 1 commit into
Simon (simonhj) wants to merge 1 commit into
Conversation
af9fbc3 to
5d6facb
Compare
…very `findWorkspaceRoots` walks the tree from cwd and returns every directory containing MODULE.bazel / WORKSPACE / WORKSPACE.bazel. Monorepos host multiple workspace roots (e.g. examples/<name>/MODULE.bazel, mobile/ MODULE.bazel under an otherwise non-Bazel root); the per-workspace algorithm in the orchestrator runs once per discovered root. Pruning matches the previous lockfile walker: skip the usual non-workspace directories (.git, node_modules, .socket-auto-manifest, etc.), Bazel's `bazel-*` output_base symlinks (so we never recurse into tens of GiB of generated state), and `dist*` build-output directories. Caps `MAX_WALK_DEPTH` and `MAX_WORKSPACE_ROOTS` guard against pathological inputs and symlink loops. Pure-function module with no Bazel calls; unit tests use a tmpdir fixture tree and cover the root-only, nested, prune, symlink, and sort-determinism cases.
5d6facb to
2641c7e
Compare
Author
|
Consolidating into a single PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This is the first of a five-PR series rewriting
socket manifest bazel'sMaven extraction path to (a) discover nested workspaces, and (b) replace
static Starlark parsing with Bazel-native discovery. The full series:
(1) workspace walker (this PR — pure helper, no callers yet);
(2)
bazel mod show_extensionparser + tri-state probe primitives + per-invocation
--output_user_rootplumbing in the runner;(3) per-repo metadata cquery
(4) orchestrator rewrite that wires (1)–(3) together and removes the
legacy Starlark-regex discovery + kind-only probe;
(5) customer
--bazel-flag/--bazel-startup-flag/--bazel-maven-repopassthrough for matrix builds. Each PR is independently green (typecheck +
tests); follow-up PRs depend on this branch but this branch leaves the
orchestrator untouched, so the walker arrives as unused code until (4)
lands.
This greatly simplifies things, the [ast
Summary
Adds
findWorkspaceRoots({ cwd, ignoreDirNames?, ignoreDirPrefixes?, verbose? })— a pure-function file-tree walker that returns every directory containing
a Bazel workspace marker (
MODULE.bazel,WORKSPACE, orWORKSPACE.bazel).Real-world monorepos host multiple workspace roots: Today
socket manifest bazelonly inspects the invocation cwd, so anythingunder a nested workspace is silently invisible. This walker is the
building block for fixing that.
Behaviour
cwd; yields every directory whoseimmediate children include a workspace marker file.
(root
MODULE.bazel+examples/*/MODULE.bazel) are common; bothare reported.