Repository navigation
Commit 6ba1936
Run the hosted Go flow on real Bazel in CI (#2107)
* Run the hosted Go flow on real Bazel in CI
socket-patch has no Bazel-specific code, and until now no test ran it
in a Bazel workspace. This adds a test target that does, and a workflow
that runs it on pinned Bazel releases. No file under crates/*/src
changes.
The first tests hold hosted mode for a Go module that comes through
gazelle's go_deps.from_file under Bzlmod, on Bazel 9.3.2, 8.8.2 and
7.7.2. Each one, in a fresh output base:
- builds the fixture workspace and reads "OUT: PRISTINE" from
`bazel run //:consumer`;
- runs `scan --mode hosted --yes`, which rewrites go.mod and go.sum
and nothing else;
- runs the same two Bazel commands and reads the patched marker, which
holds an id made for the run: the Socket module came from the
stand-in patch host, Bazel changed no file of the checkout, and a
`--lockfile_mode=error` build passes;
- runs `rollback --yes`: every file of the checkout is the one of
before, byte for byte, and the build prints "OUT: PRISTINE" again;
- builds the rewritten checkout in a second output base against a
patch host that serves other bytes: the build fails on the sum.
The Socket API, the Go proxy, the patch host and the checksum-database
lookup are one loopback wiremock server, and `go` is given no public
proxy. The Bazel registry, the ruleset archives, the Go release list
and the Go SDK come from the network. Bazel 9's repository contents
cache stays on, as a user has it, with one cache per workspace copy.
- crates/socket-patch-cli/tests/e2e_bazel_build/: harness.rs keeps
every Bazel write inside a per-test scratch root (startup options,
environment, repository cache, contents cache, server shutdown) and
runs the socket-patch child; go.rs builds the two modules, the
stand-in and the flow. The tests are #[ignore]d and print SKIP
without a Bazel, or fail when SOCKET_PATCH_BAZEL_E2E_REQUIRED is
set. Two hermetic tests run on every Unix runner.
- crates/socket-patch-cli/tests/fixtures/bazel/gazelle/bzlmod/{e9,e7}:
the two workspaces (gazelle 0.54.0 with rules_go 0.65.0, and gazelle
0.45.0 with rules_go 0.53.0 for Bazel 7).
- scripts/install-bazel.sh and scripts/bazel-pins.txt: one Bazel
release binary, checked against a pinned sha256 before it is
installed.
- .github/workflows/bazel-compatibility.yml: one Linux leg per Bazel
release on a pull request that touches these files or a Go file the
tests run through, on a main push that also touches the shared
engine code and test helpers, nightly and on dispatch; one macOS leg
nightly and on dispatch. Not required for merge.
A later test of the same flow is one fixture directory and one test
function. A new Bazel major adds its pin lines and one matrix line; a
new ecosystem adds its module and one matrix line per release.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Tighten the Bazel end-to-end harness after review
The real-Bazel test of the hosted Go flow asserts what it asserted. This
changes how a leg selects it, what it takes from the machine it runs on,
and how its Bazel is installed.
- A flow is one `#[ignore]` test, `go::hosted_go_deps`. It takes its
release from the Bazel it is given (`bazel --version`) and its fixture
era from one table in the test code, `go::FIXTURE`; a release the table
does not hold fails with a message that names the table. The workflow
passes the module filter `go::`: no name prefix derived from the
release, no assert on test names, no scrape of the log.
`SOCKET_PATCH_BAZEL_E2E_VERSION` fails a leg whose Bazel is not its
release, as `SOCKET_PATCH_GO_E2E_VERSION` does for Go.
- The fixture is one `common` directory and one `MODULE.bazel` per era,
in place of two full copies. A hermetic test holds the directories to
the table and the one `go.sum` to the module the test serves.
- The Go fetch settings that gazelle hands to `go mod download`
(`GOPRIVATE`, `GONOPROXY`, `GONOSUMDB`, `GOSUMDB`, `GOAUTH`), and
`GOFLAGS` and `GOINSECURE`, are pinned beside `GOPROXY`, as variables
of the Bazel client and as `--repo_env`. An exported
`GOPRIVATE=patch.socket.dev` used to send the fetch past the loopback
stand-ins to the real host.
- `XDG_CONFIG_HOME`, `XDG_DATA_HOME` and `XDG_STATE_HOME` are removed
from every Bazel child, so on Linux the telemetry counters of the Go
SDK land under the scratch home. `GOTELEMETRY` is not set: `go env`
reports it, and Go does not read it from the environment.
- A bazelisk launcher gets one `BAZELISK_HOME`, the caller's own cache,
so it downloads a release at most once, not once per workspace copy.
- A relative `SOCKET_PATCH_BAZEL_E2E_BAZEL` or
`SOCKET_PATCH_BAZEL_E2E_SOCKET_BIN` fails at once with a message that
names the variable, with or without
`SOCKET_PATCH_BAZEL_E2E_REQUIRED`.
- `scripts/install-bazel.sh` gives curl a connect timeout, a low-speed
limit and a total time, and retries only transient failures: a 404
goes to the second origin at once and a stalled transfer ends. It
prints one line on stdout, and the documented recipe is
`export "$(scripts/install-bazel.sh <version> <dir>)"`, which keeps a
space in the path.
- The workflow's jobs have no `name:`. GitHub showed the matrix
expressions of the name as text for a job that its `if` skipped.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Share the Bazel test harness across ecosystems, one workflow each
The Go flow kept to itself what any flow on a real Bazel needs, and the
workflow had one path list and one matrix for every ecosystem. A second
ecosystem would copy the first, and each would start its legs on every
change to the other.
harness.rs now holds what the flows share:
- StandIn, the loopback server behind the hosts of a flow (start,
origin, serve, api, requests, asked), and the steps a flow is made
of: the unpatched build with Bazel's lock, the envelope and the files
of a hosted scan, the patched build that changes no file and passes
with a frozen lock, and the undo. go.rs uses them and asserts what it
asserted before.
- Cell::route_downloads and rewrite, for a ruleset that fetches with
Bazel's own downloader: a downloader config beside the workspace
copy, named on every later command of the cell and of its twin by
the option of the release (--experimental_downloader_config before
Bazel 8.2.0, --downloader_config from there on; 8.2.0 and later still
take the old name, with a warning). A rule quotes its URL prefix, so
a `.` or a `+` in a file name is no pattern. Cell::numbers gives a
flow the parsed release.
- The environment of every Bazel child. The tool settings of a
developer's shell no longer reach the repository rules and
`bazel run`: GEM_HOME, GEM_PATH, NODE_OPTIONS, NODE_PATH, PYTHONHOME,
PYTHONPATH, PYTHONSTARTUP, PIP_* and UV_*, and through the scrubs of
tests/common/hermetic.rs BUNDLE_*, RUBYOPT, RUBYLIB, npm_config_*,
PNPM_* and VIRTUAL_ENV, beside the Go settings removed before. The
proxy of the machine stays, because a build may need it to reach the
Bazel registry, and loopback is added to no_proxy and NO_PROXY:
without it Bazel's downloader asks the proxy for a stand-in's URL.
Two hermetic tests hold this. One checks the option name, and the
config a cell and its twin name. The other starts the test binary again
with every removed variable and a proxy set, and reads the environment
of a child spawned there.
.github/workflows/bazel-compatibility.yml becomes a reusable workflow
that holds the legs: the Linux matrix, the macOS job, the installer,
the caches, the REQUIRED and VERSION settings and the
BAZEL_COMPAT_DISABLED switch. .github/workflows/bazel-go.yml calls it
with the Go module, fixture and releases, under its own triggers, path
lists and concurrency group. Another ecosystem adds a caller and
touches neither file. A pull request run covers the ecosystem's own
flow and fixture, the harness, the installer with its pins and the two
workflows; shared engine code is covered on the push to main and
nightly, as before.
The repository cache is one per ecosystem and fixture era now, not one
per Bazel release: the legs of one era share it. A caller names the era
of each release it runs, and Fixture::check fails when that is not the
era the test code's table gives the release. The run step fails when
its module filter matches no test, which would pass with nothing run.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Hold the scrubbed environment list in its test, and pick Bazel tests by exact name
The test that a Bazel child sees none of a shell's tool settings read
its names from the two lists it was meant to guard, so a name dropped
from either still passed. The names are now written out in the test,
and the test also fails when a list gains a name it does not cover.
Dropping GEM_HOME, the PIP_ prefix or the virtualenv scrub each fails
it.
The run step chose an ecosystem's tests with a libtest filter, which is
a substring: `go::` is also inside `cargo::`. It now lists the ignored
tests, keeps the names that start with the module, and runs those by
exact name; it still fails when the module has no test.
The header of bazel-pins.txt names the callers as the place that says
which releases run.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* Give the nightly Bazel run of the Go caller a concurrency group of its own
A concurrency group holds one pending run. In the group of main's
pushes, a second push replaces a nightly run that waits behind the
first, and the nightly is the only run with the macOS leg and the only
run for a main change outside the push path list.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>1 parent 3b14afc commit 6ba1936
13 files changed
Lines changed: 2078 additions & 0 deletions
File tree
- .github/workflows
- crates/socket-patch-cli/tests
- e2e_bazel_build
- fixtures/bazel/gazelle/bzlmod
- common
- e7
- e9
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
0 commit comments