Skip to content

Commit 8b35075

Browse files
BtXinclaude
andauthored
fix(build): pin Rust via rust-toolchain.toml to keep Docker and CI in lockstep (#189)
* fix(build): pin Rust via rust-toolchain.toml to keep Docker and CI in lockstep The release Docker build failed because the aws-smithy crates locked in Cargo.lock (pulled in by the S3/object-store support, #171) require rustc 1.94.1, while the Dockerfile builder image was pinned to rust:1.94.0-slim. CI never caught it because workflows installed the floating `stable` toolchain. Make the Rust version a single source of truth: - Add rust-toolchain.toml pinning 1.96.1. rustup resolves it for any cargo invocation in the repo, including inside the Docker build (COPY . . brings it in), so the image compiles with the pinned version even if the base-image tag drifts. - Bump the Dockerfile builder to rust:1.96.1-slim so the preinstalled toolchain matches the pin (tag match only avoids a download). - Replace dtolnay/rust-toolchain@stable and `rustup toolchain install stable` across all workflows with a bare `rustup toolchain install`, which installs the file-pinned version (rustup >= 1.28). CI now fails loudly on future dependency MSRV bumps until the pin is raised, instead of the drift surfacing only at release time. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(ci): install rustfmt component for the pinned toolchain The old `rustup toolchain install stable` was a no-op because runners preinstall stable with rustfmt included. The pinned 1.96.1 toolchain is a fresh install under the runner's minimal rustup profile, which has no rustfmt, so `cargo fmt --check` failed. Add it alongside llvm-tools-preview in the test job's install step. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(ci): add components via rustup component add, not install flags A bare `rustup toolchain install` (no toolchain argument) installs exactly what rust-toolchain.toml specifies and silently ignores CLI --component flags, so rustfmt was still missing and `cargo fmt --check` failed again. Add rustfmt and llvm-tools-preview in a separate `rustup component add` step, which targets the active file-pinned toolchain and cannot be skipped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 11c25ba commit 8b35075

7 files changed

Lines changed: 35 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v4
2626
- name: Install Rust toolchain
27-
uses: dtolnay/rust-toolchain@stable
27+
# No toolchain argument: rustup installs the version pinned in
28+
# rust-toolchain.toml, keeping CI in lockstep with the Docker build.
29+
run: rustup toolchain install
2830
- uses: Swatinem/rust-cache@v2
2931
- name: Install protoc
3032
run: sudo apt-get install -y protobuf-compiler
@@ -157,7 +159,15 @@ jobs:
157159
sudo apt-get update
158160
sudo apt-get install -y protobuf-compiler
159161
- name: Install Rust
160-
run: rustup toolchain install stable --component llvm-tools-preview
162+
# Version comes from rust-toolchain.toml. Runners install the pinned
163+
# toolchain with the minimal profile, and a bare `rustup toolchain
164+
# install` ignores CLI --component flags in favor of the toolchain
165+
# file's spec — so components must be added in a second command.
166+
# Kept out of the toolchain file so the Docker build doesn't pull
167+
# them: rustfmt is for `cargo fmt`, llvm-tools-preview for coverage.
168+
run: |
169+
rustup toolchain install
170+
rustup component add rustfmt llvm-tools-preview
161171
- name: Install cargo-llvm-cov
162172
uses: taiki-e/install-action@cargo-llvm-cov
163173
- name: install nextest

.github/workflows/docs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ jobs:
3131
- uses: actions/checkout@v4
3232

3333
- name: Install Rust toolchain
34-
uses: dtolnay/rust-toolchain@stable
34+
# No toolchain argument: rustup installs the version pinned in
35+
# rust-toolchain.toml, keeping CI in lockstep with the Docker build.
36+
run: rustup toolchain install
3537

3638
- name: Cache cargo registry
3739
uses: actions/cache@v4

.github/workflows/draft-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ jobs:
6262
echo "Next version: v${NEXT}-rc.${RC_NUM}"
6363
6464
- name: Install Rust
65-
run: rustup toolchain install stable
65+
# Version comes from rust-toolchain.toml.
66+
run: rustup toolchain install
6667

6768
- name: Bump version in Cargo.toml and open PR
6869
id: pr

.github/workflows/promote-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ jobs:
4848
echo "Promoting $RC_TAG -> $OFFICIAL"
4949
5050
- name: Install Rust
51-
run: rustup toolchain install stable
51+
# Version comes from rust-toolchain.toml.
52+
run: rustup toolchain install
5253

5354
- name: Bump version in Cargo.toml and open PR
5455
id: pr

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ jobs:
106106
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
107107
108108
- name: Install Rust
109+
# Version comes from rust-toolchain.toml.
109110
run: |
110-
rustup toolchain install stable
111+
rustup toolchain install
111112
rustup target add ${{ matrix.target }}
112113
113114
- uses: Swatinem/rust-cache@v2
@@ -273,7 +274,8 @@ jobs:
273274
sudo apt-get install -y protobuf-compiler
274275
275276
- name: Install Rust
276-
run: rustup toolchain install stable
277+
# Version comes from rust-toolchain.toml.
278+
run: rustup toolchain install
277279

278280
- uses: Swatinem/rust-cache@v2
279281

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Build stage
2-
FROM rust:1.94.0-slim AS builder
2+
# The Rust version is pinned by rust-toolchain.toml (copied in with the source),
3+
# which rustup honors even if this tag drifts. Keep the tag matching the pin so
4+
# the build uses the preinstalled toolchain instead of downloading one.
5+
FROM rust:1.96.1-slim AS builder
36

47
RUN apt-get update && apt-get install -y \
58
pkg-config \

rust-toolchain.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Single source of truth for the Rust version used by local dev, CI, and the
2+
# Docker image build. rustup resolves this file automatically for any cargo or
3+
# rustup invocation inside the repo, so all environments build with the same
4+
# compiler. Keep the builder tag in Dockerfile in sync when bumping: a matching
5+
# tag only avoids a toolchain download at image-build time — correctness comes
6+
# from this file either way.
7+
[toolchain]
8+
channel = "1.96.1"

0 commit comments

Comments
 (0)