Skip to content

ci: gate released CHANGELOG sections against their tags; advisory step in the release ritual (#1101, #828) - #1177

Merged
scttfrdmn merged 1 commit into
mainfrom
ci/1101-828-release-ritual
Oct 19, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
ci/1101-828-release-ritual

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1101
Fixes #828

#1101: released CHANGELOG sections must match their tags

New changelog_released_test.go adds TestChangelogReleasedSectionsMatchTheirTags:

  • Discovers every ## [X.Y.Z] heading in CHANGELOG.md and compares that section, byte for byte after CRLF and trailing-blank-line normalisation, with the same section in vX.Y.Z:CHANGELOG.md. It reads every tag's file in one git cat-file --batch.
  • Tags whose tree has no CHANGELOG.md (v0.42.0 and earlier) are skipped. Only the newest section may be untagged, because the release PR merges before the tag is pushed. An untagged section anywhere else fails.
  • No tags, or no git: under CI=true the test fails; locally it skips with a git fetch --tags hint. Discovery that finds no headings, or compares no sections, fails.
  • Both CI test jobs (Test and Test (Windows), since the root package runs on Windows too) get a Fetch release tags step: git fetch --no-tags --depth=1 origin '+refs/tags/v*:refs/tags/v*'. I measured it on a fresh depth-1 clone at about 11s and 285 MB. fetch-depth: 0 would be 364 MB. A blobless fetch made the first lookup take 48s, because trees came lazily.

Historic drift (the two the issue found) needs your decision. Both are currently accepted in a short acceptedReleasedEdits map. Each entry is pinned by the SHA-256 of the section's current text, so the section is frozen again in that form. A further edit fails, and so does an entry whose section has been restored.

If you'd rather restore either one, delete its map entry and restore the section from the tag. The test will tell you if the entry goes stale.

Watched failing against compiling reverts (the reverts edit CHANGELOG.md, so the code compiles unchanged):

edit result
A new entry line under [0.135.1] ### Security (the #1101 shape) FAIL, naming the line + (now only)
An entry line deleted from [0.132.2] (the #1103 shape) FAIL, naming the line - (at tag only)
[0.126.0] (accepted) edited again FAIL, with old and new SHA-256
An untagged [0.134.9] inserted mid-file FAIL
An untagged newest [0.135.2] (release PR before its tag) PASS, logged as "the release being cut"
Run in a git init dir with no tags, CI unset SKIP
Same with CI=true, and in a non-git dir with CI=true FAIL
Run in a depth-1 clone after the tag fetch, CI=true (the CI shape) PASS

It passes on current main.

#828: advisory step in the release ritual

CLAUDE.md, under "On release", gets two additions:

  • Step 5: set patched_versions only on advisories whose fix is an ancestor of the tag (git merge-base --is-ancestor <fix> vX.Y.Z^{}). The PATCH replaces the whole vulnerabilities array, so the given gh api | jq | gh api -X PATCH builds it from the advisory as read and changes only that field. Then re-read the advisory and trim the "not yet released" note. Publishing, or keeping a draft private, remains the owner's decision.
  • A short note that released sections are now frozen by the gate above.

scripts/advisory-status.sh (optional helper) is read-only and not a CI gate, since it needs a token that can see the advisories. It lists each advisory's state, range and patched version, and flags two cases:

Exit codes: 0 when nothing is flagged, 1 when something is, 2 on an empty list or a usage error. Against the live repo today it reports nothing flagged (exit 0). With a fake gh it produces STALE, NO-TAG, "no fixed release yet" (in range), the multi-clause range >= a, < b, and exit 2 on an empty list. It passes shellcheck.

Not verified: I didn't run the PATCH command. I only checked the payload jq produces from a live GET (package, vulnerable_version_range, vulnerable_functions preserved, patched_versions set). The CI tag-fetch step runs for the first time on this PR.

Checks

GOTOOLCHAIN=go1.26.9 make check passes fmt, vet, GOOS vet, hermetic tests (root package ok), nested modules and tidy. Two expected failures:

semgrep --config=auto --error on the changed files is clean.

@scttfrdmn scttfrdmn added this to the v0.135.2 milestone Oct 19, 2026
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…p in the release ritual (#1101, #828)

#1101: TestChangelogReleasedSectionsMatchTheirTags compares every
`## [X.Y.Z]` section with the same section in `git show vX.Y.Z:CHANGELOG.md`
(one `git cat-file --batch`, CRLF and trailing blank lines normalised).
Versions are discovered from the headings; tags without a CHANGELOG.md
(v0.42.0 and earlier) are skipped; only the newest section may be untagged
(the release PR merges before its tag). No tags or no git: FAIL under CI=true,
skip locally. Both CI test jobs (Linux, Windows) now fetch the v* tags at
depth 1.

Two historic edits are accepted, each pinned by the SHA-256 of its current
text so it is frozen again: [0.126.0] holds four entries that shipped in
0.127.0, and [0.97.0] had its duplicate groups consolidated.

#828: CLAUDE.md "On release" gains the advisory step (set patched_versions
only where the fix is an ancestor of the tag, preserving the rest of the
vulnerabilities array; publishing is the owner's decision) and a note that
released sections are frozen. scripts/advisory-status.sh is a read-only
helper that flags STALE (published, empty, a release outside the range
exists) and NO-TAG (patched_versions names an untagged version).

Fixes #1101
Fixes #828
@scttfrdmn
scttfrdmn force-pushed the ci/1101-828-release-ritual branch from bc2683a to b76aa78 Compare October 19, 2026 06:07
@scttfrdmn
scttfrdmn merged commit 4c9afad into main Oct 19, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the ci/1101-828-release-ritual branch October 19, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant