This is an automated email from the ASF dual-hosted git repository.

viirya pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-connect-gateway.git


The following commit(s) were added to refs/heads/main by this push:
     new 11e9cd9  [SPARK-60853] Build with --locked in CI and the Dockerfile so 
Cargo.lock is enforced
11e9cd9 is described below

commit 11e9cd9a9ce775174567c942ed74b8f7908e77f5
Author: Liang-Chi Hsieh <[email protected]>
AuthorDate: Tue Nov 3 23:18:14 2026 -0800

    [SPARK-60853] Build with --locked in CI and the Dockerfile so Cargo.lock is 
enforced
    
    ### What changes were proposed in this pull request?
    
    Add `--locked` to every cargo command in `.github/workflows/ci.yml` that
    resolves dependencies (clippy, build, test, the ignored Redis and tracing
    integration tests, and the `drain_smoke` / `ha_smoke` examples), and to the
    release `cargo build` in the `Dockerfile`. The e2e jobs build their image 
from
    the `Dockerfile`, so they are covered too. `cargo fmt` does not resolve
    dependencies and is unchanged. The `cargo install` in `audit.yml` already
    uses `--locked`.
    
    ### Why are the changes needed?
    
    Without `--locked`, cargo silently re-resolves on the runner when 
`Cargo.lock`
    is out of date with the manifests, for example a stale dependency list in an
    entry or a version that no longer satisfies a requirement. The job then 
passes
    with a lockfile that differs from the one committed, so a broken 
`Cargo.lock`
    can be merged without CI noticing. This matters most for lockfile-only 
changes
    such as dependabot PRs and RustSec updates, where the lockfile is the entire
    change.
    
    For the `Dockerfile` it also matters for releases: without `--locked`, the
    dependency versions in a published image are not guaranteed to match the
    `Cargo.lock` in the source release.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. CI and image build configuration only. Building the image now fails if
    `Cargo.lock` is out of date, instead of silently updating it.
    
    ### How was this patch tested?
    
    This PR's own CI run is the main test: every changed step runs with the new
    flag. Locally, on the pinned 1.99.0 toolchain against `main`'s `Cargo.lock`:
    
    - `cargo clippy --workspace --all-targets --locked -- -D warnings`, `cargo
      build --workspace --locked`: clean.
    - `cargo test --workspace --locked`: 204 passed, 0 failed.
    - `cargo test -p scg-proxy --test tracing_integration --locked -- 
--ignored`:
      passed. `cargo run -p scg-proxy --example drain_smoke --locked`: all drain
      invariants passed. The Redis test and `ha_smoke` were compiled with
      `--locked`; running them needs the CI Redis service.
    - `Cargo.lock` was not modified by any of the above.
    - Negative check: with `memchr` removed from `pulldown-cmark`'s dependency
      list in `Cargo.lock`, `cargo build -p scg-genproto --locked` fails with
      "cannot update the lock file ... because --locked was passed". Without
      `--locked` the same build succeeds and quietly rewrites the lockfile, 
which
      is the behavior CI has today.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Yes, co-authored with Claude Code.
    
    Closes #59 from viirya/SPARK-60853.
    
    Authored-by: Liang-Chi Hsieh <[email protected]>
    Signed-off-by: Liang-Chi Hsieh <[email protected]>
---
 .github/workflows/ci.yml | 17 ++++++++++-------
 Dockerfile               |  4 +++-
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 583ad55..38fb7ec 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -59,14 +59,17 @@ jobs:
       - name: Format check
         run: cargo fmt --all -- --check
 
+      # Every cargo command below passes --locked: without it, cargo silently
+      # re-resolves on the runner when Cargo.lock is out of date with the
+      # manifests, and the job passes with a lockfile that was never committed.
       - name: Clippy
-        run: cargo clippy --workspace --all-targets -- -D warnings
+        run: cargo clippy --workspace --all-targets --locked -- -D warnings
 
       - name: Build
-        run: cargo build --workspace
+        run: cargo build --workspace --locked
 
       - name: Test
-        run: cargo test --workspace
+        run: cargo test --workspace --locked
 
   integration:
     name: integration tests
@@ -107,7 +110,7 @@ jobs:
       # a Docker daemon, and these tests bring up their own Redis container via
       # testcontainers, so run them explicitly here.
       - name: Redis integration tests
-        run: cargo test -p scg-store-redis -p scg-ratelimit -- --ignored
+        run: cargo test -p scg-store-redis -p scg-ratelimit --locked -- 
--ignored
 
       # Run the OpenTelemetry tracing test on its own, not as part of a
       # workspace-wide run. Cargo unifies features across the workspace, and 
with
@@ -116,16 +119,16 @@ jobs:
       # application spans, so the test's span assertions only hold when it is
       # built by itself. Hence `#[ignore]` plus this dedicated step.
       - name: Tracing integration test
-        run: cargo test -p scg-proxy --test tracing_integration -- --ignored
+        run: cargo test -p scg-proxy --test tracing_integration --locked -- 
--ignored
 
       # Two `examples/` binaries assert end-to-end invariants but were only 
ever
       # compiled, never executed. They exit non-zero on failure, so run them.
       # `drain_smoke` is fully in-process; `ha_smoke` needs the Redis service
       # above to share affinity state between its two gateway replicas.
       - name: Graceful-drain smoke (in-process)
-        run: cargo run -p scg-proxy --example drain_smoke
+        run: cargo run -p scg-proxy --example drain_smoke --locked
 
       - name: Multi-replica HA smoke (Redis-backed)
-        run: cargo run -p scg-proxy --example ha_smoke
+        run: cargo run -p scg-proxy --example ha_smoke --locked
         env:
           REDIS_URL: redis://127.0.0.1:6399
diff --git a/Dockerfile b/Dockerfile
index 583f74b..9c29f3a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,7 +30,9 @@ RUN apt-get update && apt-get install -y 
--no-install-recommends \
     protobuf-compiler libprotobuf-dev && \
     rm -rf /var/lib/apt/lists/*
 COPY . .
-RUN cargo build --release --bin gateway
+# --locked builds exactly the dependency versions in the committed Cargo.lock,
+# and fails instead of re-resolving if it is out of date.
+RUN cargo build --release --locked --bin gateway
 
 FROM gcr.io/distroless/cc-debian12:nonroot
 COPY --from=build /src/target/release/gateway /gateway


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to