Skip to content

fix(ci): make the Rust pipeline deterministic and green - #52

Merged
keanji-x merged 1 commit into
mainfrom
fix/ci-deterministic-toolchain
May 26, 2026
Merged

fix(ci): make the Rust pipeline deterministic and green#52
keanji-x merged 1 commit into
mainfrom
fix/ci-deterministic-toolchain

Conversation

@keanji-x

Copy link
Copy Markdown
Collaborator

Problem

Rust CI is red on main and on PRs (e.g. #50). The Check job fails at the
fmt step, which blocks Build (needs: check).

The failure was confusing because cargo fmt --all -- --check passes locally
but fails in CI
. Root cause: gravity_bench ships no rustfmt.toml of its
own.

  • In CI it is checked out standalone, so rustfmt falls back to its
    defaults91 files are reported non-compliant → fmt fails.
  • Locally it lives nested under the gravity-sdk monorepo, so rustfmt
    walks up and silently uses the parent gravity-sdk/rustfmt.toml
    (use_small_heuristics = "Max", …) → the same tree looks clean.

Two more problems were latent behind the fmt failure (they only surface once
fmt is unblocked, so CI never reached them):

  • The toolchain floats: the workflow uses dtolnay/rust-toolchain@stable
    while the repo pins 1.91.0 via rust-toolchain.toml — non-deterministic
    (a new stable release silently changes formatter/lints).
  • Three tests would hang cargo test --all-features in CI: two
    #[tokio::test]s require a live node at localhost:8545, and
    test_find_account_by_address brute-forces 1,000,000 key derivations
    (observed running >60 s) for a target address not in range.

Fix

Change Why
add rustfmt.toml (use_small_heuristics = "Max", reorder_imports, use_field_init_shorthand) Make formatting self-contained — identical standalone (CI) or nested (local). The tree is already compliant, so this is config-only, no reformatting.
pin toolchain to 1.95.0 in rust-toolchain.toml and the workflow (dtolnay/rust-toolchain@1.95.0, both jobs) Latest stable, deterministic — no more floating @stable.
#[ignore] the 2 node-dependent tests + the 1M-key brute-force lookup They need infra / are manual utilities; run on demand with cargo test -- --ignored.

Verification (locally, toolchain 1.95.0)

cargo fmt --all -- --check     # clean (0 diffs, 0 warnings)
cargo build --release --all-features   # Finished
cargo test --all-features      # test result: ok. 2 passed; 0 failed; 3 ignored

cargo check --all-targets --all-features also passes — so all four CI steps
(fmt → check → test → build) are green.

Note: dtolnay/rust-toolchain@1.95.0 is a valid ref (the action publishes a
1.95.0 branch). The node-dependent / brute-force tests still run on demand
via cargo test -- --ignored.

🤖 Generated with Claude Code

gravity_bench has no rustfmt.toml of its own, so a standalone CI checkout
ran `cargo fmt --all -- --check` against rustfmt's *defaults* (91 files
non-compliant -> red), while a nested local checkout silently borrowed the
parent gravity-sdk rustfmt.toml -> green. The toolchain also floated
(dtolnay/rust-toolchain@stable) against the repo's pinned rust-toolchain.toml,
and three tests either need a live node or brute-force 1M key derivations,
which would hang `cargo test` once fmt was unblocked.

- add rustfmt.toml (use_small_heuristics = "Max", etc.) so formatting is
  self-contained and identical whether checked out standalone (CI) or nested
  (local); the tree is already compliant, so no reformatting is needed
- pin the toolchain to the latest stable 1.95.0 in both rust-toolchain.toml
  and the workflow (dtolnay/rust-toolchain@1.95.0) -- no more floating @stable
- #[ignore] the two node-dependent tests and the 1M-key brute-force lookup;
  run them on demand with `cargo test -- --ignored`

Verified locally under 1.95.0: cargo fmt --check clean, cargo build --release
ok, cargo test = 2 passed / 0 failed / 3 ignored.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@keanji-x
keanji-x merged commit a21582d into main May 26, 2026
2 checks passed
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.

1 participant