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

Allow publishing from workspace root. #9559

Merged
merged 2 commits into from
Jul 26, 2021
Merged

Allow publishing from workspace root. #9559

merged 2 commits into from
Jul 26, 2021

Conversation

tcmal
Copy link
Contributor

@tcmal tcmal commented Jun 9, 2021

Adds -p, --workspace, and --exclude to package and publish commands.

Uses ephemeral workspaces to avoid changing the existing functions too much.
There might be more Finished dev [unoptimized + debuginfo] target messages when packaging than there should be, I couldn't figure out what was generating them.
The tests aren't super extensive, as all the specs from arguments code should already be tested elsewhere.

Closes #7345

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 9, 2021
@ehuss
Copy link
Contributor

ehuss commented Jun 9, 2021

Thanks for the PR! I think for now, there should not be a --workspace flag. There is an issue with uploading multiple packages in quick succession. There is a brief period after a package is uploaded that it is not available in the index, which can cause published crates to fail if they require the new versions. Additionally, when publishing multiple inter-related packages, the publish process will need to start from the leaves of the dependency tree and work its way upward. For now, can this be kept to only one package?

@tcmal
Copy link
Contributor Author

tcmal commented Jun 19, 2021

I'm not sure why it's failing, I'm going to rebase and see if that fixes it

EDIT: Nevermind, I see the issue.

src/cargo/ops/cargo_package.rs Outdated Show resolved Hide resolved
src/cargo/ops/registry.rs Outdated Show resolved Hide resolved
let specs = opts.to_publish.to_package_id_specs(root_ws)?;
let mut pkgs = root_ws.members_with_features(&specs, &opts.cli_features)?;

anyhow::ensure!(pkgs.len() == 1, "can only publish one package at a time.");
Copy link
Member

Choose a reason for hiding this comment

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

Am I correct in reading this in that this will support many -p flags and and --workspace, but we'll just return an error if they get matched? If so, can this error be elaborated a bit as to why multiple packages aren't supported at this time? (perhaps linking to a tracking issue?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't take --workspace, but it will take multiple -p flags. Like @ehuss said this is due to an issue with crates.io, I couldn't find any tracking issue on their repo.

@bors
Copy link
Contributor

bors commented Jul 2, 2021

☔ The latest upstream changes (presumably #9645) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

Sorry about the long delay.

src/bin/cargo/commands/publish.rs Outdated Show resolved Hide resolved
src/cargo/ops/cargo_package.rs Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Jul 22, 2021

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Jul 22, 2021

📌 Commit ae44e7cd6fb43a30b43080c8292d21c1dee0ff4f has been approved by ehuss

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 22, 2021
@bors
Copy link
Contributor

bors commented Jul 22, 2021

⌛ Testing commit ae44e7cd6fb43a30b43080c8292d21c1dee0ff4f with merge 0f6642d170827f55f00eff5e537faf59f7b35ebd...

@bors
Copy link
Contributor

bors commented Jul 22, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 22, 2021
tests/testsuite/publish.rs Outdated Show resolved Hide resolved
tcmal and others added 2 commits July 26, 2021 16:31
adds -p, --workspace, and --exclude to package command,
and -p to publish command, as well as tests for both.

closes #7345
@ehuss
Copy link
Contributor

ehuss commented Jul 26, 2021

Thanks! I pushed a small change to remove the unnecessary format!.

@bors r+

@bors
Copy link
Contributor

bors commented Jul 26, 2021

📌 Commit 30ff842 has been approved by ehuss

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 26, 2021
@bors
Copy link
Contributor

bors commented Jul 26, 2021

⌛ Testing commit 30ff842 with merge 9bc7a37...

@bors
Copy link
Contributor

bors commented Jul 26, 2021

☀️ Test successful - checks-actions
Approved by: ehuss
Pushing 9bc7a37 to master...

@bors bors merged commit 9bc7a37 into rust-lang:master Jul 26, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jul 27, 2021
Update cargo

8 commits in cebef2951ee69617852844894164b54ed478a7da..d21c22870e58499d6c31f1bef3bf1255eb021666
2021-07-22 13:01:52 +0000 to 2021-07-26 20:23:21 +0000
- Fix version string. (rust-lang/cargo#9727)
- Allow publishing from workspace root. (rust-lang/cargo#9559)
- Better msg for wrong position (rust-lang/cargo#9723)
- Stabilize the rustc-link-arg option (rust-lang/cargo#9557)
- Warning when using features in replace (rust-lang/cargo#9681)
- Refactor if let chains to matches! macro (rust-lang/cargo#9721)
- Weather is not nice today.. (rust-lang/cargo#9720)
- Update should_use_metadata function (rust-lang/cargo#9653)
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jul 27, 2021
Update cargo

8 commits in cebef2951ee69617852844894164b54ed478a7da..d21c22870e58499d6c31f1bef3bf1255eb021666
2021-07-22 13:01:52 +0000 to 2021-07-26 20:23:21 +0000
- Fix version string. (rust-lang/cargo#9727)
- Allow publishing from workspace root. (rust-lang/cargo#9559)
- Better msg for wrong position (rust-lang/cargo#9723)
- Stabilize the rustc-link-arg option (rust-lang/cargo#9557)
- Warning when using features in replace (rust-lang/cargo#9681)
- Refactor if let chains to matches! macro (rust-lang/cargo#9721)
- Weather is not nice today.. (rust-lang/cargo#9720)
- Update should_use_metadata function (rust-lang/cargo#9653)
bors added a commit that referenced this pull request Jul 30, 2021
Some minor updates for package/publish package selection.

This is just a few small things I missed in the review of #9559.

* Don't include the deprecated `--all` flag in `cargo package`.
* Update the man pages for the new flags.
@ehuss ehuss added this to the 1.56.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't publish from workspace root, no -p option
5 participants