Skip to content

rust: add support for finding packages in virtual workspaces#1180

Merged
j178 merged 7 commits intoj178:masterfrom
lmmx:virtual-workspaces
Dec 4, 2025
Merged

rust: add support for finding packages in virtual workspaces#1180
j178 merged 7 commits intoj178:masterfrom
lmmx:virtual-workspaces

Conversation

@lmmx
Copy link
Collaborator

@lmmx lmmx commented Dec 2, 2025

What's new:

  • ability to run the typos-src hook in the crate-ci/typos repo
  • various new unit tests covering different types of workspace including virtual workspaces
  • use cargo_metadata to get package binary info robustly (+1.22% or +0.2MB binary size)

Status

  • Ready to review (merge if happy)

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.74%. Comparing base (3ff564e) to head (6f20aa7).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1180      +/-   ##
==========================================
+ Coverage   89.70%   89.74%   +0.03%     
==========================================
  Files          77       78       +1     
  Lines       14599    14737     +138     
==========================================
+ Hits        13096    13225     +129     
- Misses       1503     1512       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

📦 Cargo Bloat Comparison

Binary size change: +1.83% (16.4 MiB → 16.7 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text     Size          Crate Name
 0.6%   1.3% 104.8KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.3% 100.4KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  54.6KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.7%  53.0KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.3%   0.6%  48.6KiB           prek prek::run::{{closure}}
 0.2%   0.5%  40.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  39.2KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  37.3KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.4%  35.2KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  31.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.2%   0.4%  30.1KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  28.8KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  28.1KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.3%  27.6KiB           prek prek::identify::by_extension::{{closure}}
 0.1%   0.3%  25.1KiB           prek prek::main
 0.1%   0.3%  24.4KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.3%  24.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.1%   0.3%  24.3KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.1%   0.3%  24.2KiB           prek prek::hook::HookBuilder::build::{{closure}}
 0.1%   0.3%  23.9KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
41.1%  88.8%   6.8MiB                And 10630 smaller methods. Use -n N to show more.
46.3% 100.0%   7.7MiB                .text section size, the file size is 16.7MiB

Base Branch Results

 File  .text     Size          Crate Name
 0.6%   1.4% 104.8KiB          prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.6%   1.3%  99.7KiB           prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.7%  54.6KiB           prek prek::archive::unpack::{{closure}}
 0.3%   0.7%  53.0KiB             h2 h2::proto::connection::Connection<T,P,B>::poll
 0.3%   0.6%  48.6KiB           prek prek::run::{{closure}}
 0.2%   0.5%  40.0KiB           prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.5%  39.2KiB          prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.2%   0.5%  37.3KiB regex_automata regex_automata::meta::strategy::new
 0.2%   0.5%  35.2KiB           prek prek::workspace::Workspace::discover
 0.2%   0.4%  30.1KiB           prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4%  28.8KiB           prek prek::languages::node::installer::NodeInstaller::install::{{closure}}
 0.2%   0.4%  28.1KiB             h2 h2::proto::connection::DynConnection<B>::recv_frame
 0.2%   0.4%  27.6KiB           prek prek::identify::by_extension::{{closure}}
 0.2%   0.3%  26.1KiB           prek <prek::languages::rust::rust::Rust as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.3%  25.1KiB           prek prek::main
 0.1%   0.3%  24.4KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.3%  24.4KiB           std? <core::marker::PhantomData<T> as serde_core::de::DeserializeSeed>::deserialize
 0.1%   0.3%  24.3KiB     hyper_util hyper_util::client::legacy::client::Client<C,B>::connect_to::{{closure}}::{{closure}}::{{closure}}
 0.1%   0.3%  24.2KiB           prek prek::hook::HookBuilder::build::{{closure}}
 0.1%   0.3%  23.9KiB          hyper hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
40.7%  88.6%   6.7MiB                And 10403 smaller methods. Use -n N to show more.
45.9% 100.0%   7.5MiB                .text section size, the file size is 16.4MiB

@lmmx lmmx marked this pull request as ready for review December 2, 2025 19:22
@lmmx lmmx changed the title test(tdd): find package in virtual workspace fix: find packages in virtual workspaces Dec 2, 2025
@lmmx lmmx changed the title fix: find packages in virtual workspaces fix(rust): find packages in virtual workspaces Dec 2, 2025
@lmmx lmmx force-pushed the virtual-workspaces branch from 455ea3c to 76fe2a6 Compare December 2, 2025 20:15
@lmmx lmmx force-pushed the virtual-workspaces branch from e622e9b to 3d3ce36 Compare December 2, 2025 21:02
@j178 j178 added the enhancement New feature or request label Dec 3, 2025
@j178 j178 changed the title fix(rust): find packages in virtual workspaces rust: add support for finding packages in virtual workspaces Dec 4, 2025
@j178
Copy link
Owner

j178 commented Dec 4, 2025

Thanks!

@j178 j178 merged commit dad650b into j178:master Dec 4, 2025
21 checks passed
.await?;
} else if lib_deps.is_empty() {
// For workspace members without lib deps, use cargo build + copy
// (cargo install doesn't work well with virtual workspaces)
Copy link
Contributor

Choose a reason for hiding this comment

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

What problem is this?

(context: also a cargo team member)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here I was trying to install a specific binary from its path whose metadata I got from the workspace, and tried a few ways. I ended up deciding that it’s best to just build and copy the binary rather than try to point to the subpath. I forget exactly what error I was getting but this looked like the best way to do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would assume that the same install approach should be used regardless of whether the package is in the root of a workspace or not. It keeps the code simpler and makes it faster to discover the root cause of undesired behavior.

The following seemed to work for me

cargo +nightly install -Zunstable-options --dry-run --path ../typos/crates/typos-cli/ --bins

(-Z is for --dry-run to work)

Copy link
Collaborator Author

@lmmx lmmx Dec 4, 2025

Choose a reason for hiding this comment

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

Hmmm yes let me throw this in an issue so I can come back to it...

Edit: opened #1191 to track

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

language: rust fails with virtual workspaces

3 participants