Skip to content

ci: track stable in rust-toolchain.toml, enforce MSRV in its own job - #741

Merged
lwshang merged 2 commits into
mainfrom
ci/decouple-dev-toolchain-from-msrv
Aug 5, 2026
Merged

ci: track stable in rust-toolchain.toml, enforce MSRV in its own job#741
lwshang merged 2 commits into
mainfrom
ci/decouple-dev-toolchain-from-msrv

Conversation

@lwshang

@lwshang lwshang commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

rust-toolchain.toml was pinned to the MSRV (1.88.0), so local builds, rust-analyzer and
every CI job ran on a compiler nine releases behind stable — hence the "toolchain too old"
warning rust-analyzer now emits.

This decouples the two, matching dfinity/cdk-rs:

Where Value
Development toolchain rust-toolchain.toml stable
MSRV rust-version in workspace Cargo.toml 1.88.0 (unchanged)

The MSRV itself does not change. A new msrv job in test.yml enforces it, building the
published crates with the version it reads out of Cargo.toml — so an MSRV bump stays a
one-line edit and can't drift from CI. It reports through the existing test:required
aggregate, so no branch-protection changes are needed.

The newer compiler also surfaced two latent bugs in the WASM job, both test-harness only
(d295c59): the mock service worker lost hit-counter increments when a test had two requests
in flight, and doctests now run against wasm, where ic-agent's #[tokio::main] examples
can't compile (--lib skips them; the host test job still runs them).

How Has This Been Tested?

CI is green. Every gate that now floats with the toolchain was also run locally on stable
1.97 (fmt, clippy incl. cargo hack --each-feature, wasm clippy, rustdoc) and the MSRV
builds on 1.88.0. The WASM fix was verified repeatedly on both toolchains.

Notes for reviewers

  • The msrv job is Linux-only — MSRV drift is nearly always a dependency raising its own
    rust-version, which is platform-independent. Say so if you'd rather add windows-2025.
  • release.yml now cross-builds icx with floating stable instead of a frozen 1.88.0.
  • Unrelated pre-existing issue, left alone: the WASM job's CARGO_TARGET_DIR=target/wasm
    resolves inside ic-agent/ (wasm-pack cds first), so rust-cache never caches it.

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly. — n/a: no user-visible change; MSRV unchanged, ic-agent edits are test-only.
  • I have made corresponding changes to the documentation.

lwshang and others added 2 commits August 4, 2026 09:18
rust-toolchain.toml was pinned to the MSRV (1.88.0), so every local build,
rust-analyzer, clippy and every CI job used a compiler nine releases behind
stable. That makes the repo progressively harder to work in as the MSRV ages
(rust-analyzer now refuses sufficiently old toolchains) and hides new
rustc/clippy diagnostics until the MSRV is bumped.

Split the two concerns, matching the setup in dfinity/cdk-rs:

- rust-toolchain.toml tracks `stable`.
- `rust-version` in the workspace Cargo.toml stays at 1.88.0 and becomes the
  single source of truth for the MSRV.
- A new `msrv` job in test.yml parses `rust-version` out of Cargo.toml and
  builds with that toolchain, so bumping the MSRV is a one-line change and
  cannot drift out of sync with CI.

The msrv job covers the published crates only (ref-tests and
ic-utils-bindgen-tests depend on pocket-ic from the IC monorepo, whose MSRV
runs far ahead of ours) and builds without --all-targets: the promise is that
consumers can build the libraries at the MSRV, not that our test suite runs
there. It gates on the existing `changes` filter and reports through the
existing `test:required` aggregate, so no branch-protection changes are needed.

Verified before landing: cargo fmt, `cargo hack clippy --each-feature`,
`clippy --all-targets --all-features -D warnings`, the wasm clippy target and
`RUSTDOCFLAGS=-Dwarnings cargo doc` all pass on stable 1.97, and the new msrv
commands pass on 1.88.0. No source changes were needed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…doctests

Moving rust-toolchain.toml to `stable` surfaced two latent problems in the WASM
job. Both are test-harness issues; no library code changes.

1. `agent::agent_test::no_cert` failed with "some mocked routes were never hit".
   The service-worker mock counts hits with a read-modify-write across two
   IndexedDB transactions: getMock reads the whole record, the handler mutates
   its copy, setMock writes it back. `Agent::query` issues its `query` and its
   `read_state` concurrently via `try_join!`, so both handlers read the
   pre-state and the second write discards the first one's increment. `no_cert`
   is the only test that combines concurrent requests with assert_mock (which
   requires *every* route to be hit), so it is the only one that noticed.

   Confirmed rather than inferred: the counter for the `query` route reads 0
   even though the test's MissingSignature assertion — which requires the query
   response to have been served — passes. The request happened; only its
   increment was lost.

   Fixed by serializing the service worker's handlers; the responses are canned
   data, so there is nothing to gain from overlapping them. Locally: fails 2/2
   on stable 1.97 and passes 2/2 on 1.88 before the fix, passes 3/3 on both
   after.

   assert_mock now prints the hit map on failure. The original assertion gave no
   indication of which route was missed.

2. Newer toolchains run doctests for wasm targets, which 1.88 skipped. ic-agent's
   doctests use `#[tokio::main]` and tokio is deliberately a dev-dependency only
   under cfg(not(target_family = "wasm")), so they cannot compile there:
   "cannot find module or crate `tokio`". Pass --lib so the browser run covers
   the #[wasm_bindgen_test] tests it is meant to cover; the host `test` job
   already runs the doctests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lwshang
lwshang marked this pull request as ready for review August 5, 2026 13:17
@lwshang
lwshang requested a review from a team as a code owner August 5, 2026 13:17
@zeropath-ai

zeropath-ai Bot commented Aug 5, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to d295c59.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► .github/workflows/test.yml
      Enable MSRV build steps and WASM builds
► .github/workflows/test.yml
      Modify Run Tests (WASM) command to include lib flag
Documentation / Comment Update ► Cargo.toml
      Update MSRV description and tooling guidance in comments
Documentation / Comment Update ► README.md
      Add section explaining MSRV vs development toolchain concepts
Enhancement ► ic-agent/http_mock_service_worker.js
      Serialize request handlers to ensure atomic cycles and add explanatory comments
Bug Fix / Test Enhancement ► ic-agent/src/agent/agent_test.rs
      Improve assertion message when mocked routes not hit
Configuration / Tooling ► rust-toolchain.toml
      Change development toolchain to stable and document MSRV relationship

@lwshang
lwshang merged commit e41d8ac into main Aug 5, 2026
24 checks passed
@lwshang
lwshang deleted the ci/decouple-dev-toolchain-from-msrv branch August 5, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants