Skip to content

Commit 60d0adb

Browse files
authored
Check semver compliance on release bump PRs (payjoin#1804)
2 parents e9cb409 + 6d1dc3b commit 60d0adb

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

contrib/release/check-bump.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env bash
22
#
33
# Pull request check. For each release crate whose version changed relative
4-
# to the base commit, confirm the bump is consistent (check-invariants) and
5-
# the crate still publishes (cargo publish --dry-run). No-ops when no release
6-
# version changed. A sibling release crate not yet on crates.io is skipped,
7-
# not failed, since a PR may bump two crates at once.
4+
# to the base commit, confirm the bump is consistent (check-invariants), the
5+
# crate still publishes (cargo publish --dry-run), and the bump is large
6+
# enough for the API changes since the base version (cargo semver-checks).
7+
# No-ops when no release version changed. A sibling release crate not yet on
8+
# crates.io is skipped, not failed, since a PR may bump two crates at once.
89
set -euo pipefail
910
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1011
# shellcheck source=contrib/release/crates.sh
@@ -56,3 +57,23 @@ for crate in "${changed[@]}"; do
5657
cargo publish --dry-run --locked -q -p "$crate"
5758
echo "$crate packages and publishes cleanly"
5859
done
60+
61+
# Semver only binds between stable releases: any comparison involving a
62+
# pre-release is classified as a major bump, which permits everything, so
63+
# running the tool there proves nothing. Only payjoin is checked for now;
64+
# payjoin-cli has no library API and payjoin-mailroom's is not yet stable.
65+
for crate in "${changed[@]}"; do
66+
[ "$crate" = "payjoin" ] || continue
67+
new_version="$(manifest_version "$crate")"
68+
baseline="$(version_at "$base" "$crate")"
69+
if is_prerelease "$new_version" || is_prerelease "$baseline"; then
70+
echo "Skipping $crate semver check for pre-release ($baseline -> $new_version)"
71+
continue
72+
fi
73+
if ! crate_published "$crate" "$baseline"; then
74+
echo "Skipping $crate semver check; baseline $baseline not on crates.io"
75+
continue
76+
fi
77+
echo "Checking $crate $new_version API against $baseline"
78+
cargo semver-checks --package "$crate" --baseline-version "$baseline"
79+
done

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
rust-overlay.overlays.default
6161
(final: prev: {
6262
dart = nixpkgs-unstable.legacyPackages.${system}.dart;
63+
# From unstable so it keeps pace with the rustdoc JSON format
64+
# emitted by rust-overlay's latest stable toolchain; the
65+
# release-branch nixpkgs version lags too far behind.
66+
cargo-semver-checks = nixpkgs-unstable.legacyPackages.${system}.cargo-semver-checks;
6367
rustToolchains = {
6468
msrv = prev.rust-bin.stable.${msrv-version}.default;
6569
stable = prev.rust-bin.stable.latest.default;
@@ -459,6 +463,7 @@
459463
name = "release";
460464
packages = with pkgs; [
461465
rustToolchains.stable
466+
cargo-semver-checks
462467
jq
463468
gnupg
464469
curl

0 commit comments

Comments
 (0)