Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace templates for workspace discovery in a monorepo #129

Open
jalaziz opened this issue Apr 8, 2023 · 2 comments
Open

Workspace templates for workspace discovery in a monorepo #129

jalaziz opened this issue Apr 8, 2023 · 2 comments

Comments

@jalaziz
Copy link

jalaziz commented Apr 8, 2023

We have a monorepo where we have multiple Rust workspaces, but a shared top-level target directory (with subdirectories for each project).

While testing rust-cache, I found that while it works well if you don't specify each individual project's workspace and target directory under workspaces, it works even better if you do because otherwise it ends up deleting all packages under ~/.cargo/registry.

Specifying each Rust project/workspace on a separate line is the answer, but it is a bit cumbersome when rust-cache does seem to support monorepos by looking for all Cargo.toml files.

After giving it some thought, an option may be to workspace "templates" that allow us to define auto-discovered workspace targets (e.g. {workspace} -> ../target/{workspace}).

I'd be happy to try and contribute such a feature, but wanted to see if there was any interest in this functionality or if there's a better solution.

@Swatinem
Copy link
Owner

Swatinem commented Apr 9, 2023

I believe if it is useful for you, it might be useful for a wider audience. Though admittedly, I do not fully understand the setup from your description.

@jalaziz
Copy link
Author

jalaziz commented Apr 9, 2023

Though admittedly, I do not fully understand the setup from your description.

The directory structure looks something like this:

.
├── build
│   ├── bar
│   └── foo
└── services
    ├── bar
    │   ├── Cargo.lock
    │   ├── Cargo.toml
    │   └── src
    └── foo
        ├── Cargo.lock
        ├── Cargo.toml
        └── src

The idea here being that we could specify workspaces as:

services/bar -> ../../build/bar
services/foo -> ../../build/foo

However, it would be nice if the workspaces were auto-discovered based on Cargo.toml and a "template" was applied for where the target directory can be found for each workspace. Does that make sense?

I've been trying to think of a simpler, but still general solution, but have been drawing blanks.

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

No branches or pull requests

2 participants