Hard fail semver breaks for 1.0 crates
What changed, and why it matters
This commit updates an internal CI script so that any future pull request introducing backward-incompatible API changes to the already-released 1.0 crate 'bitcoin-consensus-encoding' will cause the automated build to fail. It is a process/guardrail change, not a fix for an active security flaw.
No security action required; this is a CI hardening change. Reviewers may verify that bitcoin-consensus-encoding is correctly the only 1.0 crate in the hard-fail list and that the semver-checks invocation covers its relevant feature combinations.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch extends contrib/check-semver-pr.sh to include bitcoin-consensus-encoding in the existing cargo-semver-checks workflow and adds a SEMVER_HARD_FAIL_CRATES list. If a semver break is detected in a listed 1.0 crate, the script now writes a semver-hard-fail marker and exits with status 1, blocking the PR. No runtime code is changed.
Changed components
contrib/check-semver-pr.shInspect captured patch +26 / −0
diff --git a/contrib/check-semver-pr.sh b/contrib/check-semver-pr.sh
index 4c83b1f1..effbd532 100755
--- a/contrib/check-semver-pr.sh
+++ b/contrib/check-semver-pr.sh
@@ -16,6 +16,9 @@ set -euo pipefail
# under the hood to invoke rustdoc.
RUSTDOCFLAGS="-Z unstable-options --document-private-items --document-hidden-items --output-format=json --cap-lints=allow"
+# Crates that have reached 1.0 must not introduce semver-breaking API changes.
+SEMVER_HARD_FAIL_CRATES=("bitcoin-consensus-encoding")
+
# These will be set to the commit SHA from the PR's target branch
# GitHub Actions CI.
# NOTE: if running locally this will be set to master.
@@ -50,6 +53,11 @@ main() {
generate_json_files_no_default_features "bitcoin-io" "current"
generate_json_files_features_alloc "bitcoin-io" "current"
+ # 6. bitcoin-consensus-encoding: all-features, no-default-features and alloc feature.
+ generate_json_files_all_features "bitcoin-consensus-encoding" "current"
+ generate_json_files_no_default_features "bitcoin-consensus-encoding" "current"
+ generate_json_files_features_alloc "bitcoin-consensus-encoding" "current"
+
# Switch to target commit.
echo "Checking out target commit at $TARGET_COMMIT"
@@ -79,6 +87,11 @@ main() {
generate_json_files_no_default_features "bitcoin-io" "master"
generate_json_files_features_alloc "bitcoin-io" "master"
+ # 6. bitcoin-consensus-encoding: all-features, no-default-features and alloc feature.
+ generate_json_files_all_features "bitcoin-consensus-encoding" "master"
+ generate_json_files_no_default_features "bitcoin-consensus-encoding" "master"
+ generate_json_files_features_alloc "bitcoin-consensus-encoding" "master"
+
# Check for API semver breaks on all the generated JSON files above.
run_cargo_semver_check "bitcoin" "all-features"
run_cargo_semver_check "bitcoin" "no-default-features"
@@ -93,6 +106,9 @@ main() {
run_cargo_semver_check "bitcoin-io" "all-features"
run_cargo_semver_check "bitcoin-io" "no-default-features"
run_cargo_semver_check "bitcoin-io" "alloc"
+ run_cargo_semver_check "bitcoin-consensus-encoding" "all-features"
+ run_cargo_semver_check "bitcoin-consensus-encoding" "no-default-features"
+ run_cargo_semver_check "bitcoin-consensus-encoding" "alloc"
# Invoke cargo semver-checks to check for breaking changes
# in all generated files.
@@ -179,11 +195,21 @@ check_for_breaking_changes() {
# flag it as a breaking change
# Handle the case where FAIL is found
touch semver-break
+
+ for crate in "${SEMVER_HARD_FAIL_CRATES[@]}"; do
+ if [[ "$file" == "$crate"-* ]]; then
+ touch semver-hard-fail
+ fi
+ done
fi
done
if ! [ -f semver-break ]; then
echo "No breaking changes found"
fi
+ if [ -f semver-hard-fail ]; then
+ echo "Semver break detected in a 1.0 crate; failing CI"
+ exit 1
+ fi
}
#
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.