From cd78b41fa3571e25303d9b7b9100a71456289c26 Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Fri, 8 May 2026 18:21:21 -0500 Subject: [PATCH] test(release): replace hardcoded version assertion with CHANGELOG gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prior `package_version_is_current_hotfix_release` test was a brittle hardcoded `assert_eq!(env!("CARGO_PKG_VERSION"), "0.8.22")` that needed manual update on every release and only restated what `scripts/release/check-versions.sh` already enforces. Replace with `changelog_entry_exists_for_current_package_version`, which reads `CHANGELOG.md` and asserts a `## [X.Y.Z]` entry exists for the current `CARGO_PKG_VERSION`. No hardcoded version string — this self-updates with the workspace version bump and gates against the actual class of bug we just patched (the v0.8.21 / v0.8.22 backfill gap). --- crates/tui/src/prompts.rs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/tui/src/prompts.rs b/crates/tui/src/prompts.rs index f8af14cb..7938b96f 100644 --- a/crates/tui/src/prompts.rs +++ b/crates/tui/src/prompts.rs @@ -614,12 +614,31 @@ mod tests { assert!(prompt.contains("Approval Policy: Suggest")); } + /// Gate against shipping a release with a missing CHANGELOG entry — which + /// is exactly what happened with v0.8.21 / v0.8.22 (entries had to be + /// backfilled in v0.8.23). Asserts the top-of-file CHANGELOG contains a + /// `## [X.Y.Z]` heading matching the current `CARGO_PKG_VERSION`. No + /// hardcoded version string — the test self-updates with the workspace + /// version bump and only fires when the CHANGELOG is the missing piece. #[test] - fn package_version_is_current_hotfix_release() { - assert_eq!( - env!("CARGO_PKG_VERSION"), - "0.8.22", - "0.8.22 release branch must report the release version before publishing" + fn changelog_entry_exists_for_current_package_version() { + let version = env!("CARGO_PKG_VERSION"); + let changelog_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("..") + .join("..") + .join("CHANGELOG.md"); + let contents = std::fs::read_to_string(&changelog_path).unwrap_or_else(|err| { + panic!( + "failed to read CHANGELOG.md at {}: {err}", + changelog_path.display() + ) + }); + let header = format!("## [{version}]"); + assert!( + contents.contains(&header), + "CHANGELOG.md is missing a `{header}` entry for the current package \ + version. Add a release section at the top before tagging — see \ + docs/RELEASE_CHECKLIST.md." ); }