-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Package workspaces #13947
Package workspaces #13947
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
|
a045177
to
1ac1426
Compare
0e1e2da
to
140fc1d
Compare
☔ The latest upstream changes (presumably #14004) made this pull request unmergeable. Please resolve the merge conflicts. |
8cadf16
to
83b5ee5
Compare
I think this is ready for a look. There's a fair amount of churn in the tests: for workspace packaging we need to finish all the packaging before we start verifying, and this changes the order of console messages. I pushed as much of the test churn as I could into the first commit. |
48c6a50
to
c2d59e5
Compare
Co-Authored-By: Tor Hovland <55164+torhovland@users.noreply.github.com>
Co-Authored-By: Tor Hovland <55164+torhovland@users.noreply.github.com>
Takes local dependencies into account when packaging a workspace. Builds a temporary package registry to provide local dependencies, and overlays it on the upstream registry. This adds `--registry` and `--index` flags to `cargo package`. They act much like the same arguments to `cargo publish`, except that of course we are not actually publishing to the specified registry. Instead, these arguments affect lock-file generation for intra-workspace dependencies: when simultaneously packaging a crate and one of its dependencies, the lock-file will be generated under the assumption that the dependency will be published to the specified registry. Co-Authored-By: Tor Hovland <55164+torhovland@users.noreply.github.com>
@epage I think the latest round of comments have all been addressed now. |
@bors r+ |
☀️ Test successful - checks-actions |
Update cargo 14 commits in 5f6b9a92201d78af75dc24f14662c3e2dacbbbe1..b5d44db1daf0469b227a6211b987162a39a54730 2024-07-19 18:09:17 +0000 to 2024-07-26 21:27:12 +0000 - Package workspaces (rust-lang/cargo#13947) - test: migrate messages to snapbox (rust-lang/cargo#14242) - chore: Update dependencies (rust-lang/cargo#14299) - fix: remove rustc probe for `--check-cfg` support (rust-lang/cargo#14302) - Misc test clean up (rust-lang/cargo#14297) - Don't downgrade on prerelease `VersionReq` when update with --breaking. (rust-lang/cargo#14250) - test: Migrate some json tests to snapbox (rust-lang/cargo#14293) - Revert "fix: Ensure dep/feature activates the dependency on 2024" (rust-lang/cargo#14295) - chore: bump cargo-test-support to 0.4.0 (rust-lang/cargo#14286) - Bump to 0.83.0; update changelog (rust-lang/cargo#14285) - Improved error message when `update --breaking` invalid spec. (rust-lang/cargo#14279) - docs(test): Expand documentation of cargo-test-support (rust-lang/cargo#14272) - test: Fix some test based on rustc version (rust-lang/cargo#14282) - Use `Rc` instead of `Arc` for storing rustflags (rust-lang/cargo#14273) r? ghost
Update cargo 14 commits in 5f6b9a92201d78af75dc24f14662c3e2dacbbbe1..b5d44db1daf0469b227a6211b987162a39a54730 2024-07-19 18:09:17 +0000 to 2024-07-26 21:27:12 +0000 - Package workspaces (rust-lang/cargo#13947) - test: migrate messages to snapbox (rust-lang/cargo#14242) - chore: Update dependencies (rust-lang/cargo#14299) - fix: remove rustc probe for `--check-cfg` support (rust-lang/cargo#14302) - Misc test clean up (rust-lang/cargo#14297) - Don't downgrade on prerelease `VersionReq` when update with --breaking. (rust-lang/cargo#14250) - test: Migrate some json tests to snapbox (rust-lang/cargo#14293) - Revert "fix: Ensure dep/feature activates the dependency on 2024" (rust-lang/cargo#14295) - chore: bump cargo-test-support to 0.4.0 (rust-lang/cargo#14286) - Bump to 0.83.0; update changelog (rust-lang/cargo#14285) - Improved error message when `update --breaking` invalid spec. (rust-lang/cargo#14279) - docs(test): Expand documentation of cargo-test-support (rust-lang/cargo#14272) - test: Fix some test based on rustc version (rust-lang/cargo#14282) - Use `Rc` instead of `Arc` for storing rustflags (rust-lang/cargo#14273) r? ghost
Update cargo 14 commits in 5f6b9a92201d78af75dc24f14662c3e2dacbbbe1..b5d44db1daf0469b227a6211b987162a39a54730 2024-07-19 18:09:17 +0000 to 2024-07-26 21:27:12 +0000 - Package workspaces (rust-lang/cargo#13947) - test: migrate messages to snapbox (rust-lang/cargo#14242) - chore: Update dependencies (rust-lang/cargo#14299) - fix: remove rustc probe for `--check-cfg` support (rust-lang/cargo#14302) - Misc test clean up (rust-lang/cargo#14297) - Don't downgrade on prerelease `VersionReq` when update with --breaking. (rust-lang/cargo#14250) - test: Migrate some json tests to snapbox (rust-lang/cargo#14293) - Revert "fix: Ensure dep/feature activates the dependency on 2024" (rust-lang/cargo#14295) - chore: bump cargo-test-support to 0.4.0 (rust-lang/cargo#14286) - Bump to 0.83.0; update changelog (rust-lang/cargo#14285) - Improved error message when `update --breaking` invalid spec. (rust-lang/cargo#14279) - docs(test): Expand documentation of cargo-test-support (rust-lang/cargo#14272) - test: Fix some test based on rustc version (rust-lang/cargo#14282) - Use `Rc` instead of `Arc` for storing rustflags (rust-lang/cargo#14273) r? ghost
Adds support for packaging an entire workspace, even when there are dependencies between the crates. The generated packages should be identical to the ones produced by packaging and publishing the crates one-by-one in dependency order, but the main benefit of this PR is that the packages can be created and verified locally before anything is published.
The main mechanism is the one in #13926, where we create a temporary local registry that "overlays" the true registry. We "publish" the crates in the local registry, which enables lockfile generation and verification of the dependent crates.
This adds
--registry
and--index
flags tocargo package
. They actmuch like the same arguments to
cargo publish
, except that of coursewe are not actually publishing to the specified registry. Instead, these
arguments affect lock-file generation for intra-workspace dependencies:
when simultaneously packaging a crate and one of its dependencies, the
lock-file will be generated under the assumption that the dependency
will be published to the specified registry.
You can also publish a subset of a workspace using
-p
arguments. In this case, there will be an error unless the chosen subset contains all of the dependencies of everything in the subset.Fixes #10948. Based on #13926.
Compatibility issue
This PR introduces a case where
cargo package
will fail where it did not before: if you have a workspace containing two packages,main
anddep@0.1.0
, wheremain
depends ondep@0.1.0
anddep@0.1.0
is already published in crates.io then attempting to package the whole workspace will fail. To be specific, it will packagedep@0.1.0
successfully and then fail when trying to packagemain
because it will see the two different packages fordep@0.1.0
. Note thatcargo publish
will already fail in this scenario.This shouldn't interfere with crates.io running
cargo package
for each package to diff the.crate
filescargo package
.The failure could be avoided by changing the local overlay source to not error out if there's a duplicate package; see here. However, failing early has the advantage of catching errors early.