From bfef11dbdfb6529be5673c2fcbf87e7125db8c10 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 5 Aug 2026 18:01:24 -0500 Subject: [PATCH] fix(ci): stage band_weights.json into the prop-grid-rs build context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit json_weights_golden reads priv/algo/band_weights.json via a bare relative path. That resolves inside `cargo test` at the crate root but not inside the image build, whose context is rust/prop_grid_rs and whose WORKDIR is /src — so the test aborted with "JSON file must exist" and the build never produced an image. grid-rs CI has been red since 2fd88a94, the commit that added the test. Production still runs main-1785606663-95976b6 (95976b6b, the last green build), so every prop-grid-rs change since then — including the HRDPS rotated-pole decode fix — has silently failed to ship. Three parts: * resolve the fixture from CARGO_MANIFEST_DIR so the path no longer depends on the cwd * stage the file into the build context in the workflow * COPY it to /priv in the builder stage, where CARGO_MANIFEST_DIR/../../priv resolves from /src --- .forgejo/workflows/build-grid-rs.yaml | 8 ++++++++ rust/prop_grid_rs/Dockerfile | 6 ++++++ .../prop_grid_rs/tests/json_weights_golden.rs | 19 +++++++++++++------ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/build-grid-rs.yaml b/.forgejo/workflows/build-grid-rs.yaml index e102bb63..01d0394b 100644 --- a/.forgejo/workflows/build-grid-rs.yaml +++ b/.forgejo/workflows/build-grid-rs.yaml @@ -79,6 +79,14 @@ jobs: echo "$REGISTRY_TOKEN" | docker login "$REGISTRY" -u "$OWNER" --password-stdin + # The build context is the crate dir, but the json_weights_golden + # test compares against priv/algo/band_weights.json at the repo + # root. Stage it into the context so `cargo test` inside the image + # can reach it; without this the test aborts and no image is + # produced (grid-rs CI was red from 2fd88a94 onward). + mkdir -p rust/prop_grid_rs/priv/algo + cp priv/algo/band_weights.json rust/prop_grid_rs/priv/algo/ + DOCKER_BUILDKIT=1 docker build \ --file rust/prop_grid_rs/Dockerfile \ --build-arg BUILDKIT_INLINE_CACHE=1 \ diff --git a/rust/prop_grid_rs/Dockerfile b/rust/prop_grid_rs/Dockerfile index 08856acd..8404451e 100644 --- a/rust/prop_grid_rs/Dockerfile +++ b/rust/prop_grid_rs/Dockerfile @@ -115,6 +115,12 @@ COPY Cargo.toml Cargo.lock* ./ COPY src ./src COPY tests ./tests +# `json_weights_golden` compares the compiled-in band weights against +# priv/algo/band_weights.json, which lives outside this build context. +# The workflow stages it into the context first; WORKDIR is /src, so +# CARGO_MANIFEST_DIR/../../priv lands at /priv. +COPY priv /priv + RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \ --mount=type=cache,target=/usr/local/cargo/git,sharing=locked \ cargo clippy --release --all-targets -- -D warnings \ diff --git a/rust/prop_grid_rs/tests/json_weights_golden.rs b/rust/prop_grid_rs/tests/json_weights_golden.rs index bb84aa49..f6ad8823 100644 --- a/rust/prop_grid_rs/tests/json_weights_golden.rs +++ b/rust/prop_grid_rs/tests/json_weights_golden.rs @@ -98,12 +98,20 @@ fn assert_weights_equal(label: &str, got: &Weights, expected: &Weights) { /// threads for `#[test]` functions in this binary. static ENSURE_ENV: std::sync::Once = std::sync::Once::new(); +/// Absolute path to the repo's calibration JSON, resolved from the +/// crate root rather than the cwd. `cargo test` runs with the cwd at +/// the crate root, but the Docker build stages the file at an absolute +/// path, and a bare relative path silently resolved to a nonexistent +/// file there — which is what turned this golden test into a hard CI +/// failure that blocked every prop-grid-rs image build. +const BAND_WEIGHTS_JSON: &str = concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../priv/algo/band_weights.json" +); + fn ensure_json_env() { ENSURE_ENV.call_once(|| { - std::env::set_var( - "PROP_BAND_WEIGHTS_JSON", - "../../priv/algo/band_weights.json", - ); + std::env::set_var("PROP_BAND_WEIGHTS_JSON", BAND_WEIGHTS_JSON); }); } @@ -111,8 +119,7 @@ fn ensure_json_env() { fn json_override_weights_match_file() { ensure_json_env(); - let json_path = "../../priv/algo/band_weights.json"; - let expected = parse_json_override_weights(json_path); + let expected = parse_json_override_weights(BAND_WEIGHTS_JSON); for band in band_config::all_bands() { let w = band.weights();