You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add bazel-diff serve HTTP query service (#29) (#393)
* feat: add `bazel-diff serve` HTTP query service (#29)
Implements the "bazel-diff as a service" model from the BazelCon talk that
inspired this repo (issue #29), as a first self-contained increment: core
service + per-SHA hash cache.
New `com.bazel_diff.server` package + `serve` subcommand:
- HTTP/JSON server on the JDK's com.sun.net.httpserver (no new dependency)
with GET /health and GET /impacted_targets?from&to[&targetType].
- Per-SHA hash cache behind a byte-oriented HashCacheStorage interface
(LocalDiskHashCacheStorage impl, atomic writes); cache key folds in a
fingerprint of the query-affecting flags. The interface is ready for a
remote (e.g. S3) backend.
- GitClient/ProcessGitClient: subprocess git fetch/resolve/checkout.
- HashService (per-SHA generate+cache, single workspace lock) and
ImpactedTargetsService, which reuse CalculateImpactedTargetsInteractor so
results match `get-impacted-targets`.
- Initial `git fetch` gates readiness; a fetch failure "lame-ducks" the
instance (health stays 503) rather than self-repairing.
Query-affecting flags mirror `generate-hashes`, so hashes the service
produces match a cold CLI run.
Tests: unit tests per component plus a real end-to-end test
(E2ETest#testServeEndToEnd) that drives the live server over HTTP against a
two-commit git repo with real `bazel query`. New code is ~97% line-covered.
Docs: README "Query Service (experimental)" section, with the `serve` help
wired into the generated CLI reference.
Deferred to follow-ups: remote (S3) cache backend, OCI image, k8s manifests,
load balancing / multi-instance, dynamic scaling, git auth config.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat: add in-process JGit engine for `serve` (default)
Adds a JGit-backed GitClient so the query service performs git fetch /
resolve / checkout in-process, without forking a `git` subprocess or
requiring a `git` binary on the PATH.
- JGitClient implements the existing GitClient interface (drop-in).
- `--gitEngine` selects the backend: `jgit` (default, in-process) or
`subprocess` (shells out to --gitPath, exact C-git behavior, useful for
workspaces relying on checkout filters/hooks JGit doesn't run).
- Pins org.eclipse.jgit 5.13.x (the last Java-8-compatible line, matching
bazel-diff's documented minimum) and repins maven_install.json.
Note: "in process" removes the subprocess only; the working tree is still
materialized on disk because `bazel query` reads real files. JGit's
InMemoryRepository can't back a bazel workspace.
Tests: JGitClientTest (resolve/checkout/fetch incl. remote loop and error
paths against a real repo) + engine-selection tests; the serve E2E now
exercises JGit by default. New code remains ~97% line-covered.
Docs: README + generated serve help document --gitEngine and the on-disk
working-tree caveat.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments