Repository navigation
test(changelog): gate the release headings on the version constant and on real dates (#494) - #539
Merged
Merged
Conversation
…d on real dates (#494) Closes #494. Cutting v0.16.0 meant hand-checking that the new `## [0.16.0] - 2026-09-18` heading was a real date, was not in the future, agreed with the `version` constant, and sat above v0.15.1. Nothing in the repository checked any of that, and a hand-check is a gate that exists once. Two tests, extending changelog_test.go rather than adding a file, since it already holds the CHANGELOG-vs-version-constant checks: - `TestChangelogNewestSectionIsTheDeclaredVersion` — the top released heading names what cmd/objectfs/main.go declares. Cutting a release is two unconnected edits (promote the heading, bump the constant); doing one without the other breaks no build. - `TestChangelogSectionDatesAreRealAndInOrder` — every date parses as 2006-01-02, none is in the future, dates run non-increasing in file order, versions run strictly decreasing. Three things the file itself forced, none of them guessable: The heading regexp captures the tail as `(.*)` and parses it afterwards instead of matching `- (\d{4}-\d{2}-\d{2})`. A heading with a malformed date is the heading this test exists to report, and a regexp requiring a well-formed one cannot see it — it leaves the set and the remaining assertions pass on the headings that were already fine. The date is a fixed-width prefix of the tail, not the whole of it: `## [0.10.0] - 2026-02-23 — WITHDRAWN` annotates after the date. Anything following has to be space-separated, or the ten characters taken are the front of a longer token. Equal dates are allowed — 0.10.1, 0.10.2 and 0.10.3 all shipped on 2026-08-02 — so only an older release dated strictly later than a newer one is a contradiction. And the future check allows midnight UTC tomorrow, because a release cut from a timezone ahead of UTC can carry tomorrow's UTC date legitimately, while the mistyped year this catches is wrong by far more than a day. Non-vacuity floor of 15 headings against the 20 present; the count only grows, so it never needs raising.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #494.
Cutting v0.16.0 meant hand-checking that the new
## [0.16.0] - 2026-09-18heading was a real date,was not in the future, agreed with the
versionconstant incmd/objectfs/main.go, and sat abovev0.15.1. Nothing in the repository checked any of it. A hand-check is a gate that exists once.
Two tests, extending
internal/config/changelog_test.gorather than adding a file, since it alreadyholds the CHANGELOG-vs-version-constant checks:
TestChangelogNewestSectionIsTheDeclaredVersion— the top released heading names what thebinary reports. Cutting a release is two unconnected edits (promote
## [Unreleased], bump theconstant); doing one without the other breaks no build. Checked in file order, not by sorting,
so a new heading added below an old one fails here too.
TestChangelogSectionDatesAreRealAndInOrder— every date parses as2006-01-02, none is inthe future, dates run non-increasing in file order, versions run strictly decreasing.
Three things the file itself forced
The heading regexp captures the tail as
(.*)and parses it afterwards rather than matching- (\d{4}-\d{2}-\d{2}). A heading with a malformed date is precisely the heading this test exists toreport, and a regexp that requires a well-formed one cannot see it — the heading leaves the set and
every remaining assertion passes on the headings that were already fine.
The date is a fixed-width prefix of the tail, not the whole of it.
## [0.10.0] - 2026-02-23 — WITHDRAWNannotates after the date. Anything following has to be space-separated, or the tencharacters taken are the front of a longer token — which is its own assertion.
Equal dates are allowed. 0.10.1, 0.10.2 and 0.10.3 all shipped on 2026-08-02, so only an older
release dated strictly later than a newer one is a contradiction. Likewise the future check allows
midnight UTC tomorrow: a release cut from a timezone ahead of UTC can carry tomorrow's UTC date
legitimately, while the mistyped year this is for is wrong by far more than a day.
Non-vacuity floor of 15 headings against the 20 present. The count only grows, so it never needs
raising; its job is to fail loudly if the regexp stops matching, which would otherwise leave every
per-heading assertion trivially satisfied.
Verification
Seven mutations, each caught by a named test, none of them a build failure:
…NewestSectionIsTheDeclaredVersion,…UnreleasedComparesFromTheNewestRelease…SectionDatesAreRealAndInOrder2026-9-18…SectionDatesAreRealAndInOrder…SectionDatesAreRealAndInOrder,…SectionsAllHaveLinkReferences