Test that a published release names its tag to CI, and that the gate checks the packaging config
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user