Skip to content

feat(rust-shell): include foundry-bin for anvil-based tests#172

Merged
thedavidmeister merged 2 commits into
mainfrom
2026-05-13-foundry-in-rust-shell
May 13, 2026
Merged

feat(rust-shell): include foundry-bin for anvil-based tests#172
thedavidmeister merged 2 commits into
mainfrom
2026-05-13-foundry-in-rust-shell

Conversation

@thedavidmeister
Copy link
Copy Markdown
Contributor

@thedavidmeister thedavidmeister commented May 13, 2026

Summary

  • Add pkgs.foundry-bin to rust-build-inputs. This makes anvil available on PATH inside rust-shell and the default shell.
  • Consumers using alloy's Anvil::new().try_spawn() for local-EVM integration tests in cargo test need anvil. Without it the spawn errors Os { code: 2, kind: NotFound }. The slim rust-shell was excluding the whole sol-build-inputs set, which dragged anvil out with it.
  • Closure assertion in test/bats/devshell/rust-shell/closure.test.bats updated to allow foundry-bin while still rejecting slither/solc.
  • New anvil.test.bats asserting anvil is on PATH.

Why option 2

Two ways to fix this were considered:

  1. Introduce a new node-binding-inputs set carrying anvil and include it in rust-shell. Architectural — anvil is conceptually a node-binding test tool, distinct from sol-build (forge/slither/solc/reuse for actual Solidity work).
  2. Add pkgs.foundry-bin directly to rust-build-inputs. One-line change; brings forge/cast/chisel along but those are part of the same foundry-bin output so the closure cost is the same as just anvil.

Going with 2 — same net cost, lower diff.

Test plan

  • rust-shell-test (closure + cargo-expand + anvil) green
  • No regression on sol-shell-test
  • No regression on default-shell-test

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Foundry CLI tools are now available in the Rust development environment.
  • Tests

    • Added verification that Foundry tools are accessible in the environment.
    • Improved closure assertions for development dependencies.

Review Change Stack

Rust crates using alloy's Anvil::new().try_spawn() (for local-EVM integration tests) need the anvil binary on PATH at test time. anvil ships with foundry-bin; adding it to rust-build-inputs makes Anvil::new() work in cargo test without dragging in the rest of the Solidity static-analysis toolchain.

Closure test relaxed to assert only slither/solc absence (foundry now expected).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this May 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Warning

Rate limit exceeded

@thedavidmeister has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 2 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3af87377-e35e-4ad4-a046-f9c3e5bd973a

📥 Commits

Reviewing files that changed from the base of the PR and between 95dd5f4 and 8ac3f13.

📒 Files selected for processing (1)
  • flake.nix
📝 Walkthrough

Walkthrough

This PR adds foundry-bin to the Rust development environment, tightens closure test assertions to allow the new dependency while preventing Solidity static-analysis tool leaks, and adds a Bats test to verify the anvil command is available on PATH.

Changes

Foundry-bin integration into Rust environment

Layer / File(s) Summary
Add foundry-bin and update closure expectations
flake.nix, test/bats/devshell/rust-shell/closure.test.bats
pkgs.foundry-bin is added to rust-build-inputs. Closure test comments are updated to clarify that rust-shell may include foundry-bin but should not include solc or slither. The closure test assertion is narrowed to check only for solc-static- and slither-analyzer- paths rather than a broader pattern, allowing foundry-bin to coexist without triggering test failures.
New anvil availability test
test/bats/devshell/rust-shell/anvil.test.bats, flake.nix
A new Bats test verifies that anvil --version exits successfully, confirming the command is available on PATH. The rust-shell-test task is extended to run this new test.

Possibly related PRs

  • rainlanguage/rainix#166: Both PRs modify flake.nix's rust-shell-test/devshell Bats setup to add an additional "tool is on PATH" test (main: anvil/foundry-bin, retrieved: cargo-expand/cargo-expand).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A foundry-bin appears, so shiny and new,
Anvil takes its place in the shell, tried and true,
Closure tests now smile, knowing what's blessed,
Solc and slither stay out—only the best! 🔨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding foundry-bin (specifically anvil) to the rust-shell environment. It is concise, specific, and clearly reflects the primary objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-05-13-foundry-in-rust-shell

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/bats/devshell/rust-shell/anvil.test.bats (1)

1-4: 💤 Low value

Simple smoke test is adequate.

The test successfully verifies that anvil is available on PATH and executes without error. For enhanced robustness, you could optionally verify the output contains "anvil" or a version pattern, but the current implementation is sufficient for the stated goal.

Optional: More robust output verification
 `@test` "anvil should be available on PATH" {
   run anvil --version
   [ "$status" -eq 0 ]
+  [[ "$output" =~ anvil ]]
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/bats/devshell/rust-shell/anvil.test.bats` around lines 1 - 4, The test
"anvil should be available on PATH" currently runs `run anvil --version` and
checks exit status only; to make it more robust, after `run anvil --version` add
an assertion on `$output` (for example using `[[ "$output" =~
anvil|[0-9]+\.[0-9]+\.[0-9]+ ]]` or `[[ "$output" == *anvil* ]]`) so the test
verifies the output contains "anvil" or a version pattern in addition to
checking `$status` equals 0.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/bats/devshell/rust-shell/anvil.test.bats`:
- Around line 1-4: The test "anvil should be available on PATH" currently runs
`run anvil --version` and checks exit status only; to make it more robust, after
`run anvil --version` add an assertion on `$output` (for example using `[[
"$output" =~ anvil|[0-9]+\.[0-9]+\.[0-9]+ ]]` or `[[ "$output" == *anvil* ]]`)
so the test verifies the output contains "anvil" or a version pattern in
addition to checking `$status` equals 0.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2e3ddaf0-4eb3-4e13-a3ae-6b87e3272afb

📥 Commits

Reviewing files that changed from the base of the PR and between 49fb732 and 95dd5f4.

📒 Files selected for processing (3)
  • flake.nix
  • test/bats/devshell/rust-shell/anvil.test.bats
  • test/bats/devshell/rust-shell/closure.test.bats

@thedavidmeister thedavidmeister merged commit 998bd91 into main May 13, 2026
13 checks passed
@github-actions
Copy link
Copy Markdown

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Tip

For best results, initiate chat on the files or code changes.

SIZE=S

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