prop/.forgejo/workflows/build-grid-rs.yaml
Graham McIntire bfef11dbdf
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
fix(ci): stage band_weights.json into the prop-grid-rs build context
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
2026-08-05 18:01:24 -05:00

109 lines
3.7 KiB
YAML

name: Build prop-grid-rs
on:
push:
branches:
- main
paths:
- 'rust/prop_grid_rs/**'
- '.forgejo/workflows/build-grid-rs.yaml'
env:
REGISTRY: git.mcintire.me
OWNER: graham
IMAGE_NAME: prop-grid-rs
DOCKER_CLI_VERSION: '28.5.2'
BUILDX_VERSION: '0.35.0'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push:
name: Test, build, push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
set -euo pipefail
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --default-toolchain stable
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/prop_grid_rs/target
key: ${{ runner.os }}-cargo-${{ hashFiles('rust/prop_grid_rs/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Run clippy and tests
working-directory: rust/prop_grid_rs
run: |
cargo clippy --all-targets -- -D warnings
cargo test --release
- name: Install Docker CLI and buildx
run: |
set -euo pipefail
curl -fsSL --retry 3 --retry-delay 2 \
"https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz" \
| tar xz --strip-components=1 -C /usr/local/bin docker/docker
# Docker 23+ routes `docker build` through buildx. The static tarball
# ships only the CLI, so the plugin has to be installed separately or
# DOCKER_BUILDKIT=1 fails with "buildx component is missing".
mkdir -p "$HOME/.docker/cli-plugins"
curl -fsSL --retry 3 --retry-delay 2 \
-o "$HOME/.docker/cli-plugins/docker-buildx" \
"https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-amd64"
chmod +x "$HOME/.docker/cli-plugins/docker-buildx"
docker version
docker buildx version
- name: Build and push
env:
REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: |
set -euo pipefail
IMAGE="${REGISTRY}/${OWNER}/${IMAGE_NAME}"
SHA_TAG="main-$(date -u +%s)-${GITHUB_SHA::7}"
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 \
--cache-from "${IMAGE}:latest" \
--tag "${IMAGE}:${SHA_TAG}" \
--tag "${IMAGE}:latest" \
rust/prop_grid_rs
docker push "${IMAGE}:${SHA_TAG}"
docker push "${IMAGE}:latest"
{
echo "### Image pushed"
echo ""
echo "- \`${IMAGE}:${SHA_TAG}\`"
echo "- \`${IMAGE}:latest\`"
} >> "$GITHUB_STEP_SUMMARY"
docker image rm "${IMAGE}:${SHA_TAG}" "${IMAGE}:latest" 2>/dev/null || true
docker logout "$REGISTRY" || true