Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6f85989
Test the vendored and agent Go flows through a gazelle run on real Bazel
mikolalysenko Nov 17, 2026
cdf3a5f
Keep Go module copies under .socket out of Bazel packages
mikolalysenko Nov 17, 2026
4dfe93d
Merge remote-tracking branch 'origin/main' into bazel-small/21-go-baz…
mikolalysenko Nov 18, 2026
f67ab54
Assert the VEX document in the Bazel flows that build patched
mikolalysenko Nov 18, 2026
d12790f
Hold the VEX documents of the Bazel flows to each other after review
mikolalysenko Nov 18, 2026
fbe5db7
Read the calls of a Bazel workspace's files
mikolalysenko Nov 18, 2026
dbb795b
Bound the Bazel reader and report what it leaves unread
mikolalysenko Nov 19, 2026
7cef538
Merge remote-tracking branch 'origin/bazel-vex/01-assert-document' in…
mikolalysenko Nov 19, 2026
a4e38d7
Read a directory in the Bazel workspace as not a file on Windows
claude Nov 19, 2026
d4ca751
Merge remote-tracking branch 'origin/bazel-vex/02-reader' into bazel-…
mikolalysenko Nov 19, 2026
d3468c0
Test a hosted Maven patch beside a rules_jvm_external hub on real Bazel
mikolalysenko Nov 19, 2026
8385746
Say when a rules_jvm_external hub builds a Maven artifact that a patc…
mikolalysenko Nov 19, 2026
1e773ab
Correct what the Maven hub notice reads and where a run reports it
mikolalysenko Nov 19, 2026
8211193
Keep the coverage profile out of the Maven test's project
mikolalysenko Nov 19, 2026
244e7a8
Merge remote-tracking branch 'origin/main' into bazel-small/21-go-baz…
mikolalysenko Nov 19, 2026
216d7cf
Merge remote-tracking branch 'origin/bazel-small/21-go-bazelignore' i…
mikolalysenko Nov 19, 2026
931aed2
Merge remote-tracking branch 'origin/bazel-vex/01-assert-document' in…
mikolalysenko Nov 19, 2026
c4c90b5
Merge remote-tracking branch 'origin/bazel-vex/02-reader' into bazel-…
mikolalysenko Nov 19, 2026
462364b
Merge remote-tracking branch 'origin/main' into bazel-maven/01-hub-no…
mikolalysenko Nov 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions .github/workflows/bazel-maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Bazel patch compatibility (Maven)

# The Maven flows of the real-Bazel tests (`maven::` in `e2e_bazel_build`):
# what a hosted patch of an artifact does in a workspace whose
# rules_jvm_external hub builds that artifact from a pinned lock, on each
# Bazel release below. bazel-compatibility.yml holds the legs and what every
# ecosystem shares; this file says when the Maven legs run and on which
# releases.
#
# Each release has an era of its own, because the ruleset decides the
# format of the lock and the name of an artifact's repository:
# rules_jvm_external 7.2 on Bazel 9, 6.9 on Bazel 8 and 6.5 on Bazel 7.
#
# Beyond what every leg needs, a Maven leg downloads one JDK (the one its
# era's rules_java runs javac on, about 215 MB; each era's .bazelrc names
# it for every Java role, so no build takes a Java from the machine or
# downloads a second one), java_tools (about 50 MB), the archive of
# rules_kotlin, a Bazel module the ruleset depends on (about 45 MB),
# Coursier (about 40 MB) and a Python toolchain that a Bazel module of the
# graph asks for (about 20 MB). Its repository cache holds them and comes
# to about 400 MB (macOS arm64, Bazel 9.3.2).
#
# No leg asks a public Maven repository, for a pin or for a build. The two
# artifacts under test are made by the test, under a group only the owner
# of socket.dev can publish to Maven Central, with an id of the run in the
# jar. The fixture's hub has a name of its own, because a hub named `maven`
# also takes the artifacts that other Bazel modules add to a hub of that
# name, which a pin resolves from Maven Central. Its one repository is the
# test's loopback server: Coursier resolves the two artifacts there, the
# lock a test pins holds them alone, with the sha256 of this run's jar,
# the build takes the jar from that server, and no cache holds a jar of
# the run. Era e7 (rules_jvm_external 6.5) starts Coursier with the Java
# of JAVA_HOME, else the `java` on PATH, which the runner images have; the
# later eras use the Java embedded in Bazel.
#
# Not required for merge: no `merge_group` trigger, and no job here is a
# `needs` of ci.yml's `ci-ok`.

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
# What a pull request run covers: the Maven flows and their fixture, the
# harness and the workflows that run it, the Bazel installer and its
# pins, and the Maven files of socket-patch-core that `get --mode
# hosted` and `rollback` run through in the fixture, each by its own
# path: the pom model and the trusted checksums (formats/maven), the
# rewriter's index of a pom, the model of what Maven selects with the
# pom walk under it (the hosted lane pins only where Maven selects the
# patch's version), the crawler that says where the Maven local
# repository is, lock discovery and the upstream restore of `rollback`,
# and what socket-patch reads only in a Bazel workspace (`bazel/`: the
# hubs of MODULE.bazel and their locks). Nothing another ecosystem's
# flow owns is here, so a change to one ecosystem starts that
# ecosystem's legs only.
#
# What it does not cover: shared engine code (`rewrite_maven_pom` is in
# patch/redirect/mod.rs, the file of every ecosystem's rewriter; hosted/,
# commands/), the shared test helpers and the toolchain files. A change
# there gets its run on the push to main (when the file is in the list
# below) or in the nightly run, not on the pull request: that is the
# price of not running every ecosystem's legs on every shared change.
# On demand, workflow_dispatch runs the legs on any branch.
paths:
- '.github/workflows/bazel-maven.yml'
- '.github/workflows/bazel-compatibility.yml'
- 'scripts/install-bazel.sh'
- 'scripts/bazel-pins.txt'
- 'crates/socket-patch-cli/tests/e2e_bazel_build/maven.rs'
- 'crates/socket-patch-cli/tests/e2e_bazel_build/harness.rs'
- 'crates/socket-patch-cli/tests/fixtures/bazel/rules_jvm_external/**'
- 'crates/socket-patch-core/src/formats/maven/**'
- 'crates/socket-patch-core/src/patch/redirect/maven_index.rs'
- 'crates/socket-patch-core/src/crawlers/maven_selection.rs'
- 'crates/socket-patch-core/src/crawlers/maven_scope.rs'
- 'crates/socket-patch-core/src/crawlers/maven_crawler.rs'
- 'crates/socket-patch-core/src/vex/discover/maven.rs'
- 'crates/socket-patch-core/src/patch/redirect/upstream/maven.rs'
- 'crates/socket-patch-core/src/bazel/**'
push:
branches: [main]
# The pull request paths, and what only a push to main covers: the
# root of the test target (it changes when an ecosystem's module is
# added; ci.yml builds the target and runs its hermetic tests on every
# pull request), the shared engine code and test helpers the flows run
# through, and the toolchain files. A main push outside this list waits
# for the nightly run below.
paths:
- '.github/workflows/bazel-maven.yml'
- '.github/workflows/bazel-compatibility.yml'
- 'scripts/install-bazel.sh'
- 'scripts/bazel-pins.txt'
- 'crates/socket-patch-cli/tests/e2e_bazel_build/maven.rs'
- 'crates/socket-patch-cli/tests/e2e_bazel_build/harness.rs'
- 'crates/socket-patch-cli/tests/fixtures/bazel/rules_jvm_external/**'
- 'crates/socket-patch-core/src/formats/maven/**'
- 'crates/socket-patch-core/src/patch/redirect/maven_index.rs'
- 'crates/socket-patch-core/src/crawlers/maven_selection.rs'
- 'crates/socket-patch-core/src/crawlers/maven_scope.rs'
- 'crates/socket-patch-core/src/crawlers/maven_crawler.rs'
- 'crates/socket-patch-core/src/vex/discover/maven.rs'
- 'crates/socket-patch-core/src/patch/redirect/upstream/maven.rs'
- 'crates/socket-patch-core/src/bazel/**'
- 'crates/socket-patch-cli/tests/e2e_bazel_build/main.rs'
- 'crates/socket-patch-core/src/patch/redirect/**'
- 'crates/socket-patch-core/src/hosted/**'
- 'crates/socket-patch-cli/src/commands/**'
- 'crates/socket-patch-cli/tests/common/**'
- 'crates/socket-patch-cli/tests/hosted_memory_common/**'
- 'Cargo.lock'
- 'Cargo.toml'
- 'crates/*/Cargo.toml'
- 'rust-toolchain.toml'
- '.cargo/**'
schedule:
# Nightly, so a main change outside the push list still gets a run
# within a day. The macOS leg runs here and on demand only.
- cron: '27 5 * * *'
workflow_dispatch:

permissions:
contents: read

# The nightly run has a group of its own. A group holds one pending run, so
# in the group of main's pushes a second push would replace a nightly that
# waits behind the first, and the nightly is the only run with the macOS leg.
concurrency:
group: bazel-maven-${{ github.event.pull_request.number || github.ref }}${{ github.event_name == 'schedule' && '-nightly' || '' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
maven:
uses: ./.github/workflows/bazel-compatibility.yml
with:
eco: maven
fixtures: rules_jvm_external/bzlmod
# One leg per line: a Bazel release, and the era of the fixture that
# `maven::FIXTURE` gives it.
releases: >-
[
{"bazel": "9.3.2", "era": "e9"},
{"bazel": "8.8.2", "era": "e8"},
{"bazel": "7.7.2", "era": "e7"}
]
macos: >-
[
{"bazel": "9.3.2", "era": "e9"}
]
2 changes: 2 additions & 0 deletions crates/socket-patch-cli/CLI_CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2533,6 +2533,8 @@ command's integration tests check its output.
| `patch_withdrawn` | `rolledBack` / `verified` (hosted event) | scan `--mode hosted`: the lockfile pinned a patch the server reports `withdrawn` or `not_found`; the pin was restored (dry run: would be) to its upstream registry entry. `reason` names the uuid and status. See "Withdrawn pins". |
| `vendor_prebuilt_stub_invalid` | `failed` | RubyGems: the server stub lacks required attributes or is otherwise invalid; no local stub fallback is permitted. |
| `bazelignore_not_updated` | run-level `warnings[]` | Go vendored and agent mode in a Bazel workspace (additive): the `.bazelignore` at the Bazel root, which keeps Bazel and gazelle out of the module copies under `.socket/vendor/golang` and `.socket/go-patches`, was not updated. It could not be read or written (a symbolic link or a directory in its place, a read-only directory, a read-only file). The detail names the line to add, or says that the lines of a copy that is gone can be deleted; the command's patch or undo stands and its exit code is unchanged. See docs/ecosystems.md "Bazel workspaces: `.bazelignore`". |
| `maven_bazel_hub_unpatched` | run-level `warnings[]` (human: `Warning: …`) | Maven in a Bazel workspace (additive): a pinned rules_jvm_external hub of the root `MODULE.bazel` fetches the jar of a Maven patch that this run pinned, vendored or applied, or tried to (`get`, `scan`, `vendor`, `apply`, in hosted, vendored and agent mode; in agent mode only for a package it found installed; never under `--global`). The hub builds the jar its own lock (`maven_install.json`) names, so the patch does not reach the Bazel build: socket-patch does not patch a hub yet. One warning per purl; the detail names the lock, the hub, and the file and line of its `maven.install`. The events, the exit code and every written file are those of the same run without the workspace. No other warning is removed or replaced for it: a hosted run of a tree without `pom.xml` gives `redirect_maven_no_pom` and, after it, this one. A `vendor` whose `--ecosystems` leaves Maven out gives none. See docs/ecosystems.md "Bazel workspaces: Maven". |
| `maven_bazel_unreadable` | run-level `warnings[]` (human: `Warning: …`) | Maven in a Bazel workspace (additive): for the same runs, whether a hub builds the jar could not be told, because something could not be read with certainty: a hub without `lock_file` (also one that only `maven.artifact` or `maven.from_toml` tags make), one of those two tags that cannot be read, a lock that is missing, empty, not format 2 or 3, larger than 16 MiB or no JSON, or a `WORKSPACE` file that calls `maven_install` or cannot be read, while `.bazeliskrc` or `.bazelversion` at the Bazel root names no release of Bazel 9 or later (three numbers, read as bazelisk reads them); and, also for a jar that a hub's lock holds, a `maven.install` whose `name` or `lock_file` is not a plain string, a construct of `MODULE.bazel` the reader does not follow, or a `maven.override` of the artifact. One warning per purl; the detail names the file, the line and the reason. Nothing else changes. |
| `vendor_*` / `pypi_*` / `gemfile_*` / `lock_*` / `locked_version_mismatch` / `user_authored_*` / `native_extensions_unsupported` / `platform_gem_unsupported` | `failed`/`skipped` | vendor: per-ecosystem refusal + drift vocabulary; see the Vendor command contract section. New tags are additive (MINOR). |

`user_patch_conflict` is a `skipped` event and a scan/apply run warning for packages
Expand Down
2 changes: 2 additions & 0 deletions crates/socket-patch-cli/src/commands/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,8 @@ pub(crate) async fn run_locked(
.collect();
run_warnings.extend(user_patch_warnings.iter().cloned());
run_warnings.extend(unsupported_warning);
let patched = results.iter().map(|r| r.package_key.as_str());
run_warnings.extend(super::bazel_maven_notices(&args.common, patched, false).await);
run_warnings.extend(results.iter().flat_map(|r| {
let note = r.error.as_deref().filter(|_| r.success).unwrap_or_default();
socket_patch_core::patch::apply::advisory_warning_codes(note)
Expand Down
31 changes: 31 additions & 0 deletions crates/socket-patch-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,37 @@ pub(crate) async fn sync_bazelignore(
warnings
}

/// In a Bazel workspace a rules_jvm_external hub builds the jars its own
/// lock pins, whatever a `pom.xml`, a Gradle build or an installed jar
/// holds (`socket_patch_core::bazel::maven`). A command that pins or
/// applies patches calls this once with the purls it was about, and hands
/// what it gets to the warnings of its run: one for each Maven jar among
/// them that a hub builds, or may build. Nothing for a `--global` run,
/// whose target is not the project, and no file is looked for when no purl
/// is a Maven one.
///
/// With `tell`, a human run is told here, as [`sync_bazelignore`] tells
/// it. A command that prints the warnings of its run itself passes
/// `false`.
pub(crate) async fn bazel_maven_notices<'a>(
common: &crate::args::GlobalArgs,
purls: impl Iterator<Item = &'a str>,
tell: bool,
) -> Vec<crate::json_envelope::RunWarning> {
if common.is_global() {
return Vec::new();
}
let purls = purls.map(str::to_string).collect();
let said = socket_patch_core::bazel::maven::notices(&common.cwd, purls).await;
let warning = |(code, detail): (&str, String)| {
if tell && !common.json && !common.silent {
eprintln!("Warning: {detail}");
}
crate::json_envelope::RunWarning::new(code, detail)
};
said.into_iter().map(warning).collect()
}

/// The vendor-ledger keys (`ledger`, the project's
/// [`VendorState::purl_keys`]) that own this run's installed copies. In
/// project scope that is the whole ledger. Under global scope the ledger
Expand Down
6 changes: 6 additions & 0 deletions crates/socket-patch-cli/src/commands/scan/hosted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,12 @@ async fn run_redirect_selected_untracked(
.iter()
.map(|w| RunWarning::new(w.code.as_str(), w.detail.as_str()))
.collect();
// What a rules_jvm_external hub of a Bazel workspace builds, no pin of
// this run reaches: said for each such artifact, beside whatever the
// rewriters said and never in their list, which is what explains a
// lock entry that was not pinned.
let hub = selected.iter().map(|(purl, _)| purl.as_str());
warnings.extend(crate::commands::bazel_maven_notices(common, hub, false).await);
warnings.extend(gem_stale.warnings.iter().map(run_warning_of));
warnings.extend(nuget_stale.warnings.iter().map(run_warning_of));
warnings.extend(python_stale.warnings.iter().map(run_warning_of));
Expand Down
6 changes: 6 additions & 0 deletions crates/socket-patch-cli/src/commands/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4441,6 +4441,12 @@ pub(crate) async fn vendor_records_reusing(
}
}

// A hub of a Bazel workspace builds the jar of its own lock, whatever
// this run vendored for the Maven or the Gradle build.
let vendored = vendorable.iter().map(String::as_str);
env.warnings
.extend(crate::commands::bazel_maven_notices(common, vendored, true).await);

// A rolled-back eject's summary would describe a vendoring that was
// undone: the eject prints it itself once it knows the outcome (#1005).
match eject {
Expand Down
9 changes: 9 additions & 0 deletions crates/socket-patch-cli/tests/e2e_bazel_build/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,15 @@ impl Cell {
self.bazel_with("update", command, args)
}

/// [`Cell::bazel`] with variables of the one command: the `REPIN=1` of
/// a ruleset's relock. Bazel's client hands its environment to the
/// repository rules and to what `bazel run` starts.
pub fn bazel_env(&self, command: &str, args: &[&str], env: &[(&str, &str)]) -> Run {
let mut cmd = self.command("update", command, args);
cmd.envs(env.iter().copied());
Run::of(cmd).unwrap_or_else(|why| panic!("{}: {why}", self.test))
}

/// `bazel build --lockfile_mode=error <targets>`: passes only when
/// `MODULE.bazel.lock` already holds what the build resolves.
fn frozen_build(&self, targets: &[&str]) -> Run {
Expand Down
1 change: 1 addition & 0 deletions crates/socket-patch-cli/tests/e2e_bazel_build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ mod cargo;
mod composer;
mod go;
mod harness;
mod maven;
mod npm;
mod nuget;
mod pypi;
Expand Down
Loading
Loading