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

Fix rustdoc .json files overwriting each other #270

Merged
merged 17 commits into from
Jan 23, 2023

Conversation

staniewzki
Copy link
Collaborator

@staniewzki staniewzki commented Jan 7, 2023

Fixes #269 and #309.

When target-dir is specified in .cargo/config.toml, the path for generated rustdoc .json file is the same for the baseline and current crate version. When generating the .json files both in advance, and them processing them later, this is obviously a problem, as one of them gets overwritten.

I don't know if the solution I have came up with is the best one, as we might load too much data into memory when processing multiple crates at once. On the other hand, this way we are sure, overwritting is not an issue.

@obi1kenobi
Copy link
Owner

Nice catch!

Would it be possible to reorganize the code to do this instead:

  • for each crate that needs to be checked:
    • generate the current rustdoc, then load it
    • generate the baseline, then load it
    • check that crate
    • move on to the next one

This way, we both don't have to worry about the files colliding or disappearing, and also we give the user feedback sooner on whether their crate passed or failed. I've recently been running cargo-semver-checks on some pretty large workspaces (dozens of crates), and I didn't love that I had to wait for all the crates' rustdocs to be generated (half an hour or more!) before any crate got checked.

@tonowak
Copy link
Collaborator

tonowak commented Jan 8, 2023

for each crate that needs to be checked: generate the current rustdoc, then load it, generate the baseline, then load it, check that crate, move on to the next one

Done.

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

Thanks to both of you for putting this together! Just some stylistic comments to help readability.

src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

The fix looks good overall. Just a small refactoring idea to look into to make it even better.

Is there a test case we could reasonably add for this? Perhaps an integration-style test on the clap release with the UnwindSafe semver issue, with a custom target dir, requiring that the semver issue be found and reported? (I.e. not just "exit 1" but also a grep in the output for the failing lint and the name of the affected type.)

src/main.rs Outdated Show resolved Hide resolved
@tonowak
Copy link
Collaborator

tonowak commented Jan 10, 2023

The fix looks good overall. Just a small refactoring idea to look into to make it even better.

Is there a test case we could reasonably add for this? Perhaps an integration-style test on the clap release with the UnwindSafe semver issue, with a custom target dir, requiring that the semver issue be found and reported? (I.e. not just "exit 1" but also a grep in the output for the failing lint and the name of the affected type.)

Sounds good. From what I remember, the semver break is exactly between clap's v3.1.18 and v3.2.0.

Copy link
Collaborator

@tonowak tonowak left a comment

Choose a reason for hiding this comment

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

Nice, I like those changes -- now it would be hard to make a similar bug.

src/main.rs Outdated Show resolved Hide resolved
@obi1kenobi obi1kenobi mentioned this pull request Jan 22, 2023
@staniewzki staniewzki requested a review from epage as a code owner January 22, 2023 11:06
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
staniewzki and others added 10 commits January 22, 2023 16:38
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
@staniewzki staniewzki force-pushed the fix-rustdoc-overwrite branch from 82a0bb3 to 62e224c Compare January 22, 2023 15:38
staniewzki and others added 4 commits January 22, 2023 16:44
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
.github/workflows/ci.yml Outdated Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
Signed-off-by: Michał Staniewski <m.staniewzki@gmail.com>
@tonowak tonowak requested a review from obi1kenobi January 23, 2023 12:20
Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

This looks great, well done @staniewzki and @tonowak!

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@obi1kenobi obi1kenobi enabled auto-merge (squash) January 23, 2023 17:34
@obi1kenobi obi1kenobi merged commit 165045b into obi1kenobi:main Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants