Plan: validate In-Network Runner (Issue #339)
Status
| Step | Description | Status |
|---|---|---|
1 |
New Dockerfile |
Done (2026-05-10) |
2 |
New xtask command |
Done (2026-05-10) |
3 |
CI wiring. Add an opt-in CI job in |
Done (2026-05-10) |
4 |
Docs. New |
Done (2026-05-10) |
Issue: #339
Branch: feat/validate-in-network-runner
Labels: type::chore, priority::medium, service::xtask, program::infrastructure, workflow::ready
Context
ADR-015 specifies that integration tests requiring PostgreSQL run inside the docker network where canopy-net already routes traffic between services. Today cargo xtask validate runs on the host; PG-touching tests need a host-local postgres reachable on localhost:5432. Contributors without host postgres get spurious failures on tests that the devstack postgres would happily serve. ADR-015’s resolution path was the in-network runner — never built.
This plan ships it as an opt-in (cargo xtask validate-in-network) so the pre-push hook stays fast on contributors who do have host postgres while contributors who don’t get a path that just works.
Scope
In scope:
-
Dockerfile.validate-runnerimage build. -
cargo xtask validate-in-networksubcommand. -
Optional
--with-devstackboot helper. -
Manual GitLab CI job exercising the path.
-
Contributor docs.
Out of scope:
-
Replacing the host-side
cargo xtask validateas the pre-push gate. This plan is additive; default flow is unchanged. -
Fully cached image distribution (e.g., publishing to a registry) — image builds on demand from the local
Dockerfile.validate-runner. Caching is up to Docker’s local layer cache. -
Cross-platform support beyond Linux + macOS. Windows is out of scope until a contributor surfaces a need.
Dependencies
-
devstack health-check helpers (
xtask/src/devstack_guard.rs) already exist. -
canopy-netnetwork already exists. -
No prerequisite plans.
Design
xtask/src/cmd/validate_in_network.rs sketch:
pub async fn run(opts: ValidateInNetworkOpts) -> Result<()> {
if opts.with_devstack {
ensure_devstack_up().await?;
} else {
check_devstack_running()?;
}
let image = build_runner_image()?;
let workspace = std::env::current_dir()?;
let status = std::process::Command::new("docker")
.args([
"run", "--rm",
"--network", "canopy-net",
"-v", &format!("{}:/work", workspace.display()),
"-w", "/work",
"-e", "CANOPY_TEST_DATABASE_URL=postgres://canopy:canopy@postgres:5432/canopy_test",
// …pass-through any other env the validate path needs…
&image,
"cargo", "xtask", "validate",
])
.status()?;
if !status.success() {
anyhow::bail!("in-network validate failed");
}
Ok(())
}
Dockerfile.validate-runner:
FROM rust:1-bookworm
RUN apt-get update && apt-get install -y --no-install-recommends \
postgresql-client git pkg-config libssl-dev \
&& rm -rf /var/lib/apt/lists/*
RUN cargo install sqlx-cli --no-default-features --features postgres,rustls
WORKDIR /work
ENTRYPOINT ["cargo"]
Image build is on-demand; first run is slow, subsequent runs hit the local Docker layer cache.
Files Touched
| File | Change |
|---|---|
|
New file |
|
New file |
|
Register the new command |
|
Add the CLI subcommand wiring |
|
Optional manual job calling |
|
New contributor doc |
|
Cross-link |
|
|
Verification
-
cargo xtask validate-in-network --with-devstackon a host with no local postgres → command succeeds. -
cargo xtask validate-in-networkon a host with devstack already up → command succeeds without rebooting devstack. -
cargo xtask validate-in-networkon a host with devstack down → command exits with a clear message pointing at--with-devstack. -
CI manual job, when triggered, completes green on a known-good commit.
-
cargo xtask validate(the host path) still works exactly as before.