From 4f2ad3b244af81e7d4a97b6c919d6b974a7f830f Mon Sep 17 00:00:00 2001 From: mhoennig Date: Thu, 3 Sep 2026 16:02:11 +0200 Subject: [PATCH] Fail the build when the project version and the release notes disagree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A version bump is manual and easy to forget on a deployment — it happened twice on 2026-09-03, leaving a running instance whose footer/--version claimed a version stale by two deployments. ReleaseVersionConsistencyTest now compares build.gradle.kts against the top entry of releases.html so a forgotten bump, or notes written for a version nothing was built as, fails before an artifact can even be produced. Co-Authored-By: Claude Sonnet 5 --- build.gradle.kts | 3 +- .../werkator/ReleaseVersionConsistencyTest.kt | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/test/kotlin/de/hoennig/werkator/ReleaseVersionConsistencyTest.kt diff --git a/build.gradle.kts b/build.gradle.kts index 68d26f7..7588aa1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,8 @@ plugins { group = "de.hoennig" // bump at least the patch version for every deployment — and only then, not per commit — // so the UI footer (BuildProperties), --version and the release notes identify what is -// actually running; a deployment bundles whatever was committed since the last one +// actually running; a deployment bundles whatever was committed since the last one. +// ReleaseVersionConsistencyTest fails the build if this and the top releases.html entry disagree. version = "1.1.0" java { diff --git a/src/test/kotlin/de/hoennig/werkator/ReleaseVersionConsistencyTest.kt b/src/test/kotlin/de/hoennig/werkator/ReleaseVersionConsistencyTest.kt new file mode 100644 index 0000000..8e2494e --- /dev/null +++ b/src/test/kotlin/de/hoennig/werkator/ReleaseVersionConsistencyTest.kt @@ -0,0 +1,29 @@ +package de.hoennig.werkator + +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe +import io.kotest.matchers.shouldNotBe +import java.io.File + +/** + * A version bump is easy to forget on a deployment (it happened twice on 2026-09-03) — this + * fails the build so a deployment can never carry an artifact whose footer/`--version` claims + * a release that has no notes, or notes for a release nothing was actually built for. + */ +class ReleaseVersionConsistencyTest : FunSpec() { + init { + test("the top release-notes entry names the current project version") { + val buildGradle = File("build.gradle.kts").readText() + val versionMatch = Regex("""^version = "([^"]+)"""", RegexOption.MULTILINE).find(buildGradle) + versionMatch shouldNotBe null + val projectVersion = versionMatch!!.groupValues[1] + + val releaseNotes = File("src/main/resources/templates/releases.html").readText() + val topHeadingMatch = Regex("""

v([0-9.]+)\s""").find(releaseNotes) + topHeadingMatch shouldNotBe null + val topReleasedVersion = topHeadingMatch!!.groupValues[1] + + topReleasedVersion shouldBe projectVersion + } + } +}