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

Improve the check public API script #59

Merged
merged 2 commits into from
Feb 1, 2024

Conversation

tcharding
Copy link
Member

Most importantly - actually run it in CI. Face palm.

Also add missing call to uniq and function-ize the script.

@apoelstra
Copy link
Member

Can't reproduce this test failure locally, even after upgrading to the latest nightly :/.

@tcharding
Copy link
Member Author

That is exactly my confusion. Locally this PR is correct but when running on the CI VM we are getting a different sort order.

@tcharding
Copy link
Member Author

This now mimics what I did in bech32 rust-bitcoin/rust-bech32#141

I"ve squashed the whole thing down into a single commit, because I"m hacking on the weekend and need to stop now. Can re split it up on Monday if required.

@apoelstra
Copy link
Member

I think the squashing is fine; I use git diff --stat and then diff individual files for these so that I can skim the API files but carefully read the others. It's a little annoying but not a big deal.

@apoelstra
Copy link
Member

But what doesn't seem fine is that it appears you've emptied all the .txt files :). I think you can't use --unique with other options and you need to manually pipe into uniq.

- name: Checkout Toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-public-api
run: cargo install --locked cargo-public-api
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to cache this.

@tcharding
Copy link
Member Author

I think you can't use --unique with other options and you need to manually pipe into uniq.

Ha! And while doing this PR I was like "hmm seems --unique is working now" - no clue how I came to that conclusion, epic fail.

@tcharding
Copy link
Member Author

I've split the PR up and been a bit more careful. The big patch (last one) is now refactor only.

@tcharding tcharding force-pushed the 01-26-sort-uniq branch 2 times, most recently from 9a6bd5b to a89611a Compare January 29, 2024 22:24
@tcharding
Copy link
Member Author

Ok, now we are back to the same problem we had days ago. The sort order produced when running the script on the CI VM is different to the sort order produced when running it locally on my machine - go figure?

I have checked the version of bash and or sort on the VM and they both match my machine.

@apoelstra
Copy link
Member

Maybe the locale differs? From my sort manpage

       *** WARNING *** The locale specified by the environment affects sort order.  Set LC_ALL=C to get the traditional sort order
       that uses native byte values.

@tcharding
Copy link
Member Author

Hot tip! I'll investigate, thanks.

@tcharding
Copy link
Member Author

Oh my goodness, it works.

@apoelstra
Copy link
Member

Lol. Everything may be a file, a text file even, but after 55 years of UNIX development I guess just there wasn't enough demand for some canonical sort order. 🙄

Can you squash this stuff into a nicer PR :)

@tcharding
Copy link
Member Author

Can you squash this stuff into a nicer PR :)

Just move the changes in the last patch to a better place, right?

@tcharding
Copy link
Member Author

Another lesson should probably be learned - RTFM ... all the way to the bottom.

@apoelstra
Copy link
Member

Another lesson should probably be learned - RTFM ... all the way to the bottom.

I'm curious when and why that warning was added to my manpage. I'll bet it is a fairly recent addition and I'll bet it doesn't show up in many sort manpages.

@apoelstra
Copy link
Member

Just move the changes in the last patch to a better place, right?

Could you squash it so that we introduce the final script in one commit, run it in another (or in the first, that's fine too), and add CI in another?

Right now pretty-much every commit is "fix the script somehow and re-run it".

Re-write the script using functions. Introduces the configuration of
locale also.

Run the scipt and include the changes to the api files. Note that there
are some additions because the old script has not been run for a while.
We have a script that checks for API changes, the intention is that PRs
that change the public API have to include a patch to the `api/foo.txt`
files. But we forgot to run it in CI - ouch.
@tcharding
Copy link
Member Author

Done (even though that makes reviewing the api file changes impossible IMO).

@apoelstra
Copy link
Member

Done (even though that makes reviewing the api file changes impossible IMO).

Because this is an initial run, I had no intention of reviewing the API file changes beyond "does it look like a lot of API surface is there and can I reproduce it".

@tcharding
Copy link
Member Author

No sweat, lets get it in.

@apoelstra
Copy link
Member

Heh, locally I get

  ┊24┊+impl core::marker::StructuralEq for hex_conservative::Case
  ┊25┊+impl core::marker::StructuralEq for hex_conservative::HexToArrayError
  ┊26┊+impl core::marker::StructuralEq for hex_conservative::HexToBytesError

which looks like it's a new nightly thing? I'm surprised CI didn't complain. My nightly is from 2024-01-20.

@apoelstra
Copy link
Member

"Structural equality" BTW is the property, roughly, where two types are equal if you can destructure (match) and eventually land on the same enum variants. It's useful for formal proofs because structural equality is something a prover can reason about, unlike the "user implemented a function called eq and it returned true" notion of equality.

@apoelstra
Copy link
Member

Oh, ran with a nightly from tonight and now it runs clean. Ok, sure.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 4148fd7

Copy link
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

ACK 4148fd7

@apoelstra apoelstra merged commit 748bf23 into rust-bitcoin:master Feb 1, 2024
10 checks passed
@tcharding tcharding deleted the 01-26-sort-uniq branch February 9, 2024 03:40
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.

3 participants