Skip to content

Commit 3a74724

Browse files
Merge rust-bitcoin/rust-secp256k1#656: Check for changes to the public API
e9e17a00393bad3db5d8d8654eb1f4bf1f20cbbb Check for changes to the public API (Tobin C. Harding) Pull request description: We would like to get to a stage where we can commit to the public API. To help us achieve this add a script that generates the public API and checks it against three committed files, one for each feature set: no features, alloc, std. The idea is that with this applied any PR that changes the public API should include a final patch that is just the changes to the api/*.txt files, that way reviewers can discuss the changes without even needing to look at the code, quickly giving concept ACK/NACKs. We also run the script in CI to make sure we have not accidentally changed the public API so that we can be confident that don't break semver during releases. The script can also be used to diff between two release versions to get a complete list of API changes, useful for writing release notes and for users upgrading. There is a development burden involved if we apply this patch. ACKs for top commit: apoelstra: ACK e9e17a00393bad3db5d8d8654eb1f4bf1f20cbbb Tree-SHA512: 94a2cedb132db457b67b3c60cde8843d9db1d2bc8dba0530cd5c518ebed955bd66a1649c61e0cb96b6f293ce6b9b0395582877ce9f1de003e0020a66100d172f
2 parents fe61da8 + 957f874 commit 3a74724

File tree

6 files changed

+4589
-0
lines changed

6 files changed

+4589
-0
lines changed

api/all-features.txt

Lines changed: 1032 additions & 0 deletions
Large diffs are not rendered by default.

api/alloc.txt

Lines changed: 897 additions & 0 deletions
Large diffs are not rendered by default.

api/default-features.txt

Lines changed: 901 additions & 0 deletions
Large diffs are not rendered by default.

api/global-context.txt

Lines changed: 923 additions & 0 deletions
Large diffs are not rendered by default.

api/no-default-features.txt

Lines changed: 804 additions & 0 deletions
Large diffs are not rendered by default.

contrib/check-for-api-changes.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Checks the public API of crates, exits with non-zero if there are currently
4+
# changes to the public API not already committed to in the various api/*.txt
5+
# files.
6+
7+
set -e
8+
9+
export RUSTDOCFLAGS='-A rustdoc::broken-intra-doc-links'
10+
REPO_DIR=$(git rev-parse --show-toplevel)
11+
API_DIR="$REPO_DIR/api"
12+
CMD="cargo +nightly public-api --simplified"
13+
14+
# cargo public-api uses nightly so the toolchain must be available.
15+
if ! cargo +nightly --version > /dev/null; then
16+
echo "script requires a nightly toolchain to be installed (possibly >= nightly-2023-05-24)" >&2
17+
exit 1
18+
fi
19+
20+
pushd "$REPO_DIR" > /dev/null
21+
$CMD --no-default-features | sort --unique > "$API_DIR/no-default-features.txt"
22+
$CMD --no-default-features --features=alloc | sort --unique > "$API_DIR/alloc.txt"
23+
$CMD | sort --unique > "$API_DIR/default-features.txt"
24+
$CMD --features=global-context | sort --unique > "$API_DIR/global-context.txt"
25+
$CMD --all-features | sort --unique > "$API_DIR/all-features.txt"
26+
27+
if [[ $(git status --porcelain api) ]]; then
28+
echo "You have introduced changes to the public API, commit the changes to api/ currently in your working directory" >&2
29+
else
30+
echo "No changes to the current public API"
31+
fi
32+
popd > /dev/null

0 commit comments

Comments
 (0)