fix(ci): stage band_weights.json into the prop-grid-rs build context
Some checks failed
Build base image / Build and push base image (push) Successful in 14s
Build and Push / Build CI test image (push) Successful in 14s
Build and Push / Build and Push Docker Image (push) Failing after 18m31s
Build prop-grid-rs / Test, build, push (push) Successful in 23m55s

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
This commit is contained in:
Graham McIntire 2026-08-05 18:01:24 -05:00
parent 289cfe5eef
commit bfef11dbdf
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59
3 changed files with 27 additions and 6 deletions

View file

@ -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 \

View file

@ -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 \

View file

@ -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();