-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add tests for --dry-run
and cargo ws plan
#157
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments to assist with the review.
README.md
Outdated
The recommended way to run tests for the crate is as follows: | ||
|
||
```sh | ||
cargo test --manifest-path cargo-workspaces/Cargo.toml -j1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fully sure if that's an appropriate fix, but it seems to work consistently.
Without it, tests were always failing. Probably this issue may be related.
README.md
Outdated
If you observe unexpected differences in snapshots, you may want to override your compiler to | ||
the same version as used in [CI](.github/workflows/ci.yml), e.g.: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is fixed on 1.70, and newer cargo doesn't emit # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
line.
Also, it looks like cargo install --path cargo-workspaces
doesn't work with 1.70, so when I worked on it, I had to manually override compiler for tests and remove an override for installation.
I guess MSRV and snapshots should be updated, but I thought it'd be an unnecessary scope extension for this PR.
I believe that this comment is useful as a general observation regardless of that.
cargo-workspaces/src/publish.rs
Outdated
@@ -46,6 +46,7 @@ pub struct Publish { | |||
|
|||
impl Publish { | |||
pub fn run(mut self, metadata: Metadata) -> Result { | |||
let mut command_success = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we no longer bail on errrors, I thought that it's weird to print success ok
if we've met problems.
c103dcd
to
5a2e280
Compare
cargo-workspaces/src/publish.rs
Outdated
@@ -100,7 +101,10 @@ impl Publish { | |||
warn!("build failed", ""); | |||
} | |||
|
|||
basic_checks(pkg)?; | |||
command_success = command_success && basic_checks(pkg)?; | |||
// We cannot use `cargo publish --dry-run` directly, because it checks if all the dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept the basic checks, but I was wondering if we still need them if --dry-run
warns about all of the issues that we check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, --dry-run
doesn't warn about them -- they are only checked during uploading.
Probably it makes sense to add this functionality to cargo
directly, I'll create an issue there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's probably the way we want to go in the future.
5a2e280
to
b20f81e
Compare
b20f81e
to
50d83ea
Compare
cargo ws publish --dry-run
, add tests for --dry-run
and cargo ws plan
--dry-run
and cargo ws plan
@pksunkara I've experimented with What would be the better way forward here? Add an extra flag to not perform |
Can you please describe them?
From what I read, the |
The recommended way to run tests for the crate is as follows: | ||
|
||
```sh | ||
cargo test --manifest-path cargo-workspaces/Cargo.toml -j1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the j1
if you add #[serial]
to all the tests.
mod utils; | ||
use insta::assert_snapshot; | ||
|
||
#[test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some test failures caused by parallel execution. #[serial]
should be added to all these tests.
Besides one that was mentioned (publishing for the first time), I've met the following error when trying to bump packages in workspace from
It's pretty weird and I'm not sure why it happens. My current hypothesis is that it's because these packages have build scripts, but I didn't investigate further so far. |
It seems to work. Try the following:
|
This is probably becasue it's the only crate in the workspace (no ws deps). Try this:
|
I have a ws project with deps where some of them are not published yet, and it's working in there. But it's not working in There are a few differences between both and I have been trying to pinpoint the issue, but unfortunately, I was not able to yet. |
Likewise. So, would it make sense to add an option to skip |
I will try to debug more on Sunday. I am currently thinking it's a bug in Skipping means, we have to skip the whole publish command. |
@pksunkara sorry for pinging, have you been able to find out the reason? |
I haven't had time to debug this, but let's resolve this week either way. Only one thing I would want to know is how does https://github.com/crate-ci/cargo-release dry run work on the same fixture? Does it give the same error as us? |
@pksunkara sorry, had a busy week. Looks like yes,
Moreover, looks like there is an open issue about that there. It doesn't look like it's easily solvable, so IMHO it probably makes sense to allow skipping actual |
Reading that issue, it looks like If it doesn't, then yeah, we should allow that. |
I think the comments there refer to some internal behavior in
|
@pksunkara Hey! Sorry, it's been a while, but I still want to drive this forward 😅 Could you please say which option sounds acceptable to you?
I'm open to other suggestions as well. |
I finally managed to run tests locally :)
This PR:
RemovesUpd: reverted.cargo publish --dry-run
step fromcargo ws publish --dry-run
(see this comment).cargo ws publish --dry-run
.cargo ws plan