Skip to content

build(fmt): extend make fmt to the Solana preset tree - #436

Open
shahan-khatchadourian-anchorage wants to merge 1 commit into
mainfrom
worktree-434-fmt-preset-tree
Open

build(fmt): extend make fmt to the Solana preset tree#436
shahan-khatchadourian-anchorage wants to merge 1 commit into
mainfrom
worktree-434-fmt-preset-tree

Conversation

@shahan-khatchadourian-anchorage

Copy link
Copy Markdown
Contributor

Summary

Closes #434.

cargo fmt cannot reach any file under chain_parsers/visualsign-solana/src/presets/*/. presets/mod.rs declares its submodules through a generated include:

include!(concat!(env!("OUT_DIR"), "/generated_presets_mod.rs"));

rustfmt does not follow an include! of a path that exists only after codegen, so it formats presets/mod.rs and stops. CI's formatting gate is make -C src generated (which calls make fmt) followed by an "Ensure working tree is clean" check, so the gate inherits the same blind spot and every preset is unchecked.

This PR:

  1. Enumerates the preset sources in the fmt target so make fmt -- and therefore the existing CI gate -- covers them. No new CI step.
  2. Reformats the 11 preset files the gate never saw.
  3. Adds src/rustfmt.toml pinning edition = "2024", so running rustfmt <file> directly on a preset produces the same result as cargo fmt and the Makefile. Bare rustfmt otherwise defaults to edition 2015.

find rather than a literal file list: presets are scaffolded one directory per program and the set grows with each new one, so a hardcoded list silently drops files out of the gate as it goes stale. The recipe echoes the file count (rustfmt 60 Solana preset sources) so a coverage regression is visible in CI logs without dumping 60 paths on one line. The target fails loudly if the directory ever moves.

The find is recursive rather than presets/*/*.rs because three files live one level deeper, under presets/*/tests/.

Files reformatted

drift, exponent_finance, jupiter_borrow, jupiter_earn, jupiter_perps,
kamino_borrow, meteora_damm_v2, meteora_dlmm, neutral_trade,
orca_whirlpool, swig_wallet

Every hunk joins lines that now fit within the width limit -- pure re-wrapping, no tokens change. Largest single change is swig_wallet/mod.rs at -13 net lines.

Test plan

  • make -C src generated then git status --porcelain is empty -- reproduces CI's gate exactly and it now passes
  • make -C src fmt is idempotent (second run produces no diff)
  • All 60 preset files pass rustfmt --check; before this change 11 failed
  • make -C src lint -- clippy clean with -D warnings
  • cargo test -p visualsign-solana -- passes

Verifying the gate actually bites

Introduce a formatting error in any preset and confirm CI now catches it:

# add a stray blank line to e.g. presets/drift/mod.rs, then:
make -C src generated && git status --porcelain   # non-empty -> gate fails the build

Note

PR #381 is where this surfaced: a struct deletion left a stray double blank line and 17 create_text_field("Raw Data", ...) calls stayed wrapped after their argument got shorter, with CI green throughout. That PR touches only presets/spl_token/mod.rs, which is not in the list above, so there is no conflict with this branch and no ordering requirement between them.

🤖 Generated with Claude Code

`cargo fmt` stops at `presets/mod.rs`, which declares its submodules
through `include!(concat!(env!("OUT_DIR"), ...))` -- rustfmt does not
follow an `include!` of a generated path, so no preset source is
formatted or checked. The CI gate (`make generated` followed by a
clean-tree check) inherits that blind spot.

Enumerate the preset sources in the `fmt` target so they are covered by
the same gate as the rest of `src/`, and reformat the 11 files that the
gate never saw. The reformat is pure re-wrapping; no tokens change.

Add `src/rustfmt.toml` pinning edition 2024 so running `rustfmt <file>`
directly on a preset matches what `cargo fmt` and the Makefile produce
(bare rustfmt otherwise defaults to edition 2015).

Closes #434

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Extends the workspace formatting gate so Solana preset sources under chain_parsers/visualsign-solana/src/presets/** (which are not reachable via cargo fmt due to an include!(OUT_DIR/...) module pattern) are formatted as part of the existing make -C src fmt / make -C src generated CI flow.

Changes:

  • Updates src/Makefile fmt target to find and run rustfmt over all Solana preset .rs sources, and fail if the preset tree can’t be found.
  • Adds src/rustfmt.toml to pin edition = "2024" for consistent direct rustfmt behavior.
  • Applies rustfmt reflow to the 11 previously-unchecked Solana preset files.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/rustfmt.toml Pins rustfmt edition to 2024 for consistent formatting runs.
src/Makefile Extends make fmt to explicitly rustfmt Solana preset sources discovered via find.
src/chain_parsers/visualsign-solana/src/presets/drift/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/exponent_finance/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/jupiter_borrow/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/jupiter_earn/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/jupiter_perps/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/kamino_borrow/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/meteora_damm_v2/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/meteora_dlmm/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/neutral_trade/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/orca_whirlpool/mod.rs Mechanical rustfmt reflow (no functional changes).
src/chain_parsers/visualsign-solana/src/presets/swig_wallet/mod.rs Mechanical rustfmt reflow (no functional changes).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chain:solana test:proptest Run the Solana property-test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: cargo fmt cannot reach the Solana preset tree; 11 preset files are misformatted

2 participants