Skip to content

Commit c74e6c4

Browse files
authored
ci: fail check-version when a PR edits the frozen CHANGELOG.md (#4594)
## Summary `CHANGELOG.md` was frozen in #4578, but nothing enforces the freeze: PRs written under the old convention still edit it. This makes the existing required `check-version` job fail when a PR changes `CHANGELOG.md`, with a message pointing to the PR title and the "Release note" section. The check lives in `scripts/check-new-release-version.sh`, with regression tests in `scripts/test-check-new-release-version.sh`. No workflow, settings or branch-protection changes are needed, because `check-version` is already a required check. ## How it decides The check compares `CHANGELOG.md` between the base that `check-version` already uses and the commit under test: - **Pull requests:** the base is the first parent of the merge ref, the `main` snapshot the merge result was built on. Only the PR's own changes count, so a stale PR that never touched the changelog still passes. - **Merge queue:** the base is the queue entry ahead, which the job already fetches. Each PR is judged only on its own change. The check runs before the version rules, so it applies whatever the version does, release PRs included. ## Validation - `shellcheck` and `shfmt -i 2 -d` are clean. `scripts/test-check-new-release-version.sh` passes 27 cases, including two new ones that edit `CHANGELOG.md` in a temporary repo: one as a merge-group entry and one as a `pull_request` merge result. Both new cases fail without this PR's script change. - Simulated locally against current `main`: - this branch, no changelog edit (queue-style base): **PASS** - PR editing `CHANGELOG.md` (queue-style base): **FAIL** with the freeze message - PR editing `CHANGELOG.md` (`pull_request` merge ref, `HEAD^1` base): **FAIL** - PR without a changelog edit (`pull_request` merge ref): **PASS** ## Release note None (CI-only).
1 parent f6ca10c commit c74e6c4

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎scripts/check-new-release-version.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ main() {
6262
else
6363
base_ref=${VERSION_BASE_REF:-origin/main}
6464
fi
65+
# CHANGELOG.md is frozen: no change may edit it, whatever the version does.
66+
if ! git diff --quiet "$base_ref" HEAD -- CHANGELOG.md; then
67+
echo 'FAIL: CHANGELOG.md is frozen. Put release notes in the PR title or its "Release note" section (see CONTRIBUTING.md).' >&2
68+
return 1
69+
fi
6570
base=$(read_version "$base_ref")
6671
elif [[ $# == 2 || $# == 3 ]]; then
6772
current=$1

‎scripts/test-check-new-release-version.sh‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,17 @@ fi
111111
EXPECT_MESSAGE="already tagged" check 1 'remote final tag prevents release' 0.27.36 0.27.36-dev
112112
git remote remove origin
113113
check 128 'tag lookup failure fails closed' 0.27.37-dev 0.27.36
114+
# The frozen changelog fails a PR whatever its version does.
115+
git checkout -q main
116+
printf 'history\n' >CHANGELOG.md
117+
git add CHANGELOG.md
118+
git commit -qm changelog
119+
changelog_base=$(git rev-parse HEAD)
120+
git checkout -qb changelog-pr
121+
printf 'new entry\n' >>CHANGELOG.md
122+
git commit -qam 'edit changelog'
123+
VERSION_BASE_REF=$changelog_base EXPECT_MESSAGE="CHANGELOG.md is frozen" check 1 'merge-group entry editing changelog fails'
124+
git checkout -q --detach "$changelog_base"
125+
git merge --no-ff -qm 'changelog PR merge result' changelog-pr
126+
VERSION_EVENT_NAME=pull_request EXPECT_MESSAGE="CHANGELOG.md is frozen" check 1 'PR merge result editing changelog fails'
114127
printf 'Passed %s version guard tests.\n' "$count"

0 commit comments

Comments
 (0)