From 478a962f34e66294d0116a451717ef4a63b467bf Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 13 Oct 2026 16:51:58 +0200 Subject: [PATCH] Test that a published release names its tag to CI, and that the gate checks the packaging config --- Dockerfile | 5 +++++ release-tooling/publish_release_test.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ace9eea..d37075d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,8 +15,13 @@ FROM python:3.14.8-slim AS release-tooling COPY release-tooling/ /release-tooling/ RUN python3 -m unittest discover -s /release-tooling -p '*_test.py' && touch /tested +FROM goreleaser/goreleaser:v2.18.3 AS packaging +COPY release-tooling/goreleaser.yaml /goreleaser.yaml +RUN goreleaser check --config /goreleaser.yaml && touch /tested + FROM portable # BuildKit skips a stage nothing copies from. COPY --from=release-tooling /tested /tmp/release-tooling-tested +COPY --from=packaging /tested /tmp/packaging-tested RUN unformatted="$(gofmt -l .)"; test -z "$unformatted" || \ { echo "unformatted files:"; echo "$unformatted"; exit 1; } diff --git a/release-tooling/publish_release_test.py b/release-tooling/publish_release_test.py index 44f0518..07eb200 100644 --- a/release-tooling/publish_release_test.py +++ b/release-tooling/publish_release_test.py @@ -25,7 +25,8 @@ class TagGuard(unittest.TestCase): self.addCleanup(os.chdir, cwd) with open("CHANGELOG.md", "w", encoding="utf-8") as f: f.write("# Changelog\n\n## [1.2.3]\n\n- A change.\n") - env = mock.patch.dict(os.environ, {"SHA": SHA}) + open("output", "w").close() + env = mock.patch.dict(os.environ, {"SHA": SHA, "GITHUB_OUTPUT": os.path.abspath("output")}) env.start() self.addCleanup(env.stop) @@ -46,6 +47,10 @@ class TagGuard(unittest.TestCase): code = publish_release.main() return code, created + def output(self): + with open("output", encoding="utf-8") as f: + return f.read() + def test_a_tag_at_another_commit_publishes_nothing(self): code, created = self.publish({"git/ref/tags/v1.2.3": {"object": {"sha": OTHER, "type": "commit"}}}) self.assertEqual((code, created), (1, [])) @@ -68,10 +73,11 @@ class TagGuard(unittest.TestCase): code, created = self.publish({}) self.assertEqual(code, 0) self.assertEqual(created, [{"body": "- A change.", "name": "v1.2.3", "tag_name": "v1.2.3", "target_commitish": SHA}]) + self.assertEqual(self.output(), "tag=v1.2.3\n") def test_a_published_release_publishes_nothing(self): code, created = self.publish({"releases/tags/v1.2.3": {"html_url": "https://forge.example/release"}}) - self.assertEqual((code, created), (0, [])) + self.assertEqual((code, created, self.output()), (0, [], "")) if __name__ == "__main__":