-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
Changed how Cargo.toml of baseline is being built, added all features to baseline's manifest #173
Changed how Cargo.toml of baseline is being built, added all features to baseline's manifest #173
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.
Excited to merge this, it looks good! Just a few small points worth discussing before we merge.
src/baseline.rs
Outdated
toml::to_string(&manifest)?.replace("edition = \"2021\"", ""), | ||
// tonowak to obi1kenobi: do you know why this replace is necessary? |
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 sure, why did you need to add it? :) Would it cause any harm to leave the edition key in the TOML?
Also, consider making these comments as GitHub comments on the PR itself for future PRs? That way we can't miss them either in terms of discussing them or in terms of remembering to remove them later when they've been sorted out.
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 sure, why did you need to add it? :) Would it cause any harm to leave the edition key in the TOML?
I had an error without removing the edition, I'll try to reproduce the error and paste it here when I'll have some time.
Also, consider making these comments as GitHub comments on the PR itself for future PRs? That way we can't miss them either in terms of discussing them or in terms of remembering to remove them later when they've been sorted out.
Sounds reasonable, but then I could forget to comment something after creating the PR...
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.
Sounds reasonable, but then I could forget to comment something after creating the PR...
You could perhaps keep these notes in a personal local file, and then turn them into comments as you open the PR? That way they aren't in the source code but they are written down before opening the PR.
I usually keep a notes file like this for myself to keep track of everything that's in progress, and I'd recommend it as a process in general.
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 had an error without removing the edition, I'll try to reproduce the error and paste it here when I'll have some time.
Error: Failed when running cargo-doc on ../rust-libp2p/target/semver-checks/registry-libp2p_core-0_37_0/Cargo.toml: error: cannot specify features for packages outside of workspace
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.
Is it perhaps getting confused about the fact that the target
dir is inside the workspace of the other Cargo.toml
? Here's what I'd suggest:
- Try reproducing the error with a manual call to cargo from the terminal.
- Then try moving the
target
directory somewhere else, outside of the workspace oflibp2p
, and try reproducing the error again with the same call.
I'm a bit worried about the edition removal because it feels like there might be a deeper issue here and the edition is just a symptom rather than the cause.
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.
The smallest breaking Cargo.toml seems to be
[package]
name = "rustdoc"
edition = "2021"
version = "0.0.0"
[workspace]
[dependencies]
libp2p = "0.37.0"
[lib]
path = "lib.rs"
with an empty lib.rs
.
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.
Re-reading the error message one more time, I think the issue is about attempting to combine --all-features
with --package libp2p-core
. The libp2p-core
package is a dependency of the project and as such its features are specified in the Cargo.toml
, so we can't run --all-features
on it because what if the Cargo.toml
entry for it specifies some other set of features? In other words, --all-features
only makes sense in the context of commands applied to the source code corresponding to the Cargo.toml
, and does not make sense for dependency packages where features are specified elsewhere.
I think the answer is to not include --all-features
in the "make fake project + get rustdoc of the dependency" branch of cargo-semver-checks
.
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 think this is the only remaining item for this PR, otherwise it's ready to merge.
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.
Sure, I'll do it in 2-3h
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 rush, whenever you have a moment is fine.
It would be great to have a test, since this is a tricky issue that would be a pain to debug again if we had a regression. What do you think would be the best and easiest way to test this? It's a little bit tricky since the issue only happens when using a baseline from crates.io.
Since we'd be emitting a brand new I'm not sure why I had a problem with This is another case of "it's better to not have to debug this later." :) |
It is tempting to add a test that checks for this problem from a selected crate from crates.io, but that would require internet connection. From one side, it seems weird to require access to crates.io during testing, but from the other side, cargo-semver-checks requires it when running the tool. What is your opinion? |
I agree we probably don't want to trigger this at How about a test script that gets run on GitHub Actions, as a sort of integration test? For example, it could clone the specific repo and commit where we found this problem, and assert that the false-positive is gone i.e. that running |
So then I would need to edit https://github.com/obi1kenobi/cargo-semver-check/blob/main/.github/workflows/ci.yml right? |
Yeah, that was what I had imagined, but I'm not tied to that idea or approach. If you have an alternative idea on how to add a regression test for this, I'd love to know about it! |
That idea seems good enough for me. I don't really see another way to test this specific problem without connecting to crates.io during |
I think I'll add an issue and try to write a new PR for the GitHub Action integration tests and leave this PR without any tests. It seems that those tests would be beneficial not only to this particular PR. What do you think? |
That sounds good. We should just avoid making new releases before those tests are in, which should be okay. |
Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
Fixes #147
Tested on the repo from this issue - seems to work. (Should I write some tests besides manually checking?)
In the issue you mentioned deleting the baseline's Cargo.lock. Is it also needed here? I don't really understand why this step is necessary.