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

[Merged by Bors] - test: Rewrite test-crate-version in Rust #2595

Closed
wants to merge 46 commits into from
Closed

[Merged by Bors] - test: Rewrite test-crate-version in Rust #2595

wants to merge 46 commits into from

Conversation

mfdorst
Copy link
Contributor

@mfdorst mfdorst commented Aug 27, 2022

Notable changes

  • Does not download https://static.crates.io/db-dump.tar.gz to check if crates are published (very slow)
    • Instead requests https://crates.io/api/v1/crates/{crate_name}/versions - 404 indicates that the crate is not published

TODO

  • Test source diffing
  • Display source changes
  • Test manifest diffing
    • Decide whether deleted manifest keys should be ignored or flagged
  • Display manifest changes
  • Download crates without an external tool (currently using cargo-download)
  • Diff source without an external tool (currently using diff) - maybe? Might not be worth the effort.
  • Add a --verbose mode
  • Download crates concurrently
  • Colorize diff

Related: #2590

@mfdorst
Copy link
Contributor Author

mfdorst commented Aug 28, 2022

Thinking of using treediff in conjunction with cargo-manifest for showing changes in manifest files.

Not sure yet how I'm gonna approach diffing the src directories - I think the current approach would not work for actually showing the differences. Possibly just using the diff command would be the simplest way, but I'd like to avoid a lot of command invocations.

There are some good crates for diffing text, but I haven't found one yet that can show differences in file structure.

Edit: I think folder_compare may be a good candidate for diffing directories

Edit 2: All of this may be overkill. What I have now seems to be working pretty well.

Testing showed that:
+ Reordering keys does not get flagged as a change (good!)
+ Removing keys also does not get flagged as a change (bad! maybe?)
@mfdorst
Copy link
Contributor Author

mfdorst commented Aug 28, 2022

So an interesting thing about the current state of the manifest diffing:

  • Reordering keys shows as no change (good!)
  • Deleting a key also shows no change (bad! or maybe potentially okay?)

I honestly don't know if this is a problem. It may even be desirable. Removing an unused dependency should not require a version bump (I think?) but there are probably other keys that ought to require a version bump if removed. But maybe this is a rare enough thing that we don't care? Feedback would be appreciated.

@mfdorst
Copy link
Contributor Author

mfdorst commented Aug 29, 2022

I couldn't find a good crate for diffing toml files, so I'm making my own. toml-diff

@sehz
Copy link
Contributor

sehz commented Aug 29, 2022

@tjtelan
Copy link
Contributor

tjtelan commented Aug 29, 2022

So an interesting thing about the current state of the manifest diffing:

* Reordering keys shows as no change (good!)

* Deleting a key also shows no change (bad! or maybe potentially okay?)

I honestly don't know if this is a problem. It may even be desirable. Removing an unused dependency should not require a version bump (I think?) but there are probably other keys that ought to require a version bump if removed. But maybe this is a rare enough thing that we don't care? Feedback would be appreciated.

The desire to have a version bump is primarily driven by our release process. Since we use path dependencies for the public crates in the repo during development and testing, we have expectations that the public version is compatible after release.

So if we could be objective in order to decide what changes require or don't require a new version bump, and cover our internal dependency tree, then that sounds ok to me. (emphasis: As long as we're consistent between our internal dependencies.)

@mfdorst
Copy link
Contributor Author

mfdorst commented Sep 2, 2022

https://github.com/infinyon/k8-api/tree/master/src/k8-diff

There might be a way to get that working for toml, but I wasn't able to easily figure it out. Good news is my toml-diff crate is coming along nicely - it's working for basic toml, though it could use some improvement on how it displays changes in nested arrays/tables.
Update: I made some improvements, I think it's complete now for what we need.

@mfdorst
Copy link
Contributor Author

mfdorst commented Sep 2, 2022

I wasn't sure if I should include the crate in the source, or if I should publish it myself and have it pull from crates.io. For now I just included the crate in the source.

@mfdorst mfdorst marked this pull request as ready for review September 6, 2022 07:29
@sehz
Copy link
Contributor

sehz commented Sep 6, 2022

Thanks for PR.
Is this ready for review?

@mfdorst
Copy link
Contributor Author

mfdorst commented Sep 6, 2022

Yes it is.

@sehz sehz requested a review from tjtelan September 6, 2022 19:05
@sehz
Copy link
Contributor

sehz commented Sep 6, 2022

Great. Thanks for the nice work!
@tjtelan Please provide feedback

Copy link
Contributor

@tjtelan tjtelan 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 like it took a lot of effort and will be a lot easier to maintain. Good job with toml-diff!

release-tools/check-crate-version/Cargo.toml Outdated Show resolved Hide resolved
release-tools/check-crate-version/src/main.rs Outdated Show resolved Hide resolved
release-tools/check-crate-version/src/main.rs Outdated Show resolved Hide resolved
release-tools/check-crate-version/toml-diff/src/lib.rs Outdated Show resolved Hide resolved
release-tools/check-crate-version/Cargo.toml Outdated Show resolved Hide resolved
release-tools/check-crate-version/src/main.rs Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@tjtelan tjtelan linked an issue Sep 8, 2022 that may be closed by this pull request
Copy link
Contributor

@tjtelan tjtelan left a comment

Choose a reason for hiding this comment

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

LGTM, I really appreciate the hard work that went into this

Copy link
Contributor

@sehz sehz left a comment

Choose a reason for hiding this comment

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

Overall looks reasonable. Just a couple of minor nits regarding the license.

Copy link
Contributor

@sehz sehz left a comment

Choose a reason for hiding this comment

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

LGTM. This is a fairly good effort. Thanks for working on this.

@sehz
Copy link
Contributor

sehz commented Sep 9, 2022

bors r+

bors bot pushed a commit that referenced this pull request Sep 9, 2022
**Notable changes**
+ Does not download `https://static.crates.io/db-dump.tar.gz` to check if crates are published (very slow)
   + Instead requests `https://crates.io/api/v1/crates/{crate_name}/versions` - 404 indicates that the crate is not published

**TODO**
+ [x] Test source diffing
+ [x] Display source changes
+ [x] Test manifest diffing
  + [x] Decide whether deleted manifest keys should be ignored or flagged
+ [x] Display manifest changes
+ [x] Download crates without an external tool (currently using `cargo-download`)
+ [ ] ~~Diff source without an external tool (currently using `diff`) - maybe? Might not be worth the effort.~~
+ [x] Add a `--verbose` mode
+ [x] Download crates concurrently
+ [x] Colorize diff

Related: #2590
@bors
Copy link

bors bot commented Sep 9, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title test: Rewrite test-crate-version in Rust [Merged by Bors] - test: Rewrite test-crate-version in Rust Sep 9, 2022
@bors bors bot closed this Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] Convert crate publish readiness checks to Rust
3 participants