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

Check for changes to the public API #2713

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tcharding
Copy link
Member

This PR is #1880 re-opened.

Add a script that checks the public API of hashes and bitcoin. Document how to use it during development. Call it in CI. Do not add it to githooks because the githooks because its expected to be run per PR not per commit.

Includes a just command to run the script: just check-api

Implied workflow change

This PR imposes workflow changes.

Explicitly: all PRs that change the public API of bitcoin, base58, hashes, io, or units must contain changes to the api text files.

Suggestion: We add the patch updating api text files as a separate patch at the end of each PR so we can haggle over it separately from the actual code changes.

Fix: #1875

@coveralls
Copy link

coveralls commented Apr 24, 2024

Pull Request Test Coverage Report for Build 8863062354

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 83.131%

Totals Coverage Status
Change from base Build 8849264030: 0.0%
Covered Lines: 19195
Relevant Lines: 23090

💛 - Coveralls

popd > /dev/null
}

# Check if there are changes (dirty git index) to the `api/` directory.
Copy link
Member

Choose a reason for hiding this comment

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

In eb1f403:

trailing whitespace

Copy link
Contributor

Choose a reason for hiding this comment

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

It is still pending this @tcharding.

Copy link
Member Author

Choose a reason for hiding this comment

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

My bad, thanks. Fixed now.

@apoelstra
Copy link
Member

Note that even though we agreed to just push forward on this, it may take a bit to get in because (a) we still need two ACKs, unless it sits open for 2 weeks without any comments, and (b) it will need to be rebased every time we merge something that changes the API.

apoelstra
apoelstra previously approved these changes Apr 25, 2024
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 d9656b9

@tcharding
Copy link
Member Author

After two months of being kind of stressed (as stressed as a bloke who works at home in tracksuit pants can be anyways) I found myself this last couple of days in a strange place of calm, just accepting that likely nothing is going to merge any time soon. Finally making some headway in hashes had me actually excited to start work this morning, first time in what seems like ages.

I kind of think we should do your idea of branching off and doing the hashes re-write then merging later when we have it nailed down. Although a bunch of my work is still so exploratory that I'm not sure which stuff is going to work. This week I already deleted a bunch of branches and started from scratch again.

api/README.md Outdated
Comment on lines 1 to 2
API text files
==============
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer that documentation is consistent.
All .md files in the repo uses the GH flavor, e.g.

# Contributing to rust-bitcoin
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
The following is a set of guidelines for contributing to Rust Bitcoin

Suggested change
API text files
==============
# API text files

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah, sure thing. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

I tend to use ==== in my own stuff so I went to check that I hadn't introduced any other files and there are tons in this repo

gg '===='
base58/README.md:2:  =======================
bitcoin/tests/data/README.md:2:  ================
bitcoin/tests/data/serde/README.md:2:  ==========================
fuzz/README.md:103:=====================================================================
internals/README.md:2:  ======================
io/README.md:2:  =======================
units/README.md:2:  =============

We should probably make them all uniform.

Copy link
Member Author

Choose a reason for hiding this comment

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

gg is an alias to git grep -IPn --color=always

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes my

All .md files

was based on a sample from the root dir .mds. I should have been more specific :/

We should definitely normalize all of them.
I can work in a future PR to normalize markdown, I am quite used from an old gig that I was in charge of technical documentation in scientific software.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sweet, nice one.

api/README.md Outdated
Comment on lines 7 to 8
Requires `cargo-public-api`, install with:

`cargo +stable install cargo-public-api --locked`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also this can be a bash fenced block no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, thanks.

We have the `$cargo_ver` variable already, use it in the error message
instead of the duplicate call to `$(cargo --version)`.
We would like to check for API changes during development and in CI so
that such changes can be discussed separately from the code.

Add tooling and documentation for creating API listings for the public
crates within the workspace (i.e., not `internals`).

Add API text files from an initial run of the script.
Add a job that runs the new script to check for changes to the public
APIs of `hashes` and `bitcoin`.
@tcharding
Copy link
Member Author

Force push is the two suggested fixes.

apoelstra
apoelstra previously approved these changes Apr 27, 2024
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 f228f54

Add a `just` command to run the API checking script. Makes it more
discoverable.
Copy link
Contributor

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

ACK 7e5ff49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check for API breaking changes in CI
4 participants