diff --git a/tooling/extension-bindings/ci/publish.py b/tooling/extension-bindings/ci/publish.py index fcd0040..3999a30 100644 --- a/tooling/extension-bindings/ci/publish.py +++ b/tooling/extension-bindings/ci/publish.py @@ -11,6 +11,7 @@ import subprocess import sys import tempfile +import time from urllib.error import HTTPError from urllib.parse import quote, urlencode from urllib.request import HTTPRedirectHandler, Request, build_opener, urlopen @@ -23,6 +24,13 @@ from serialization import read_document from generation import git, select_targets, summarize +# Right after a tag push, Go's checksum database can ask GitHub for the tag +# before GitHub serves it, answer "unknown revision", and cache that answer for +# about 30 minutes. Waiting a minute before the smoke test asks avoids that. +# If it still happens, the release is fine: run the workflow again later, and +# it reuses the tags and only repeats the smoke test. +TAG_SETTLE_SECONDS = 60 + SUFFIXES = (".module.zip", ".source.zip", ".runtimeconditions.binding-model.yaml", ".runtimeconditions.binding-release.yaml", ".runtimeconditions.bindings.yaml", ".runtimeconditions.file-manifest.yaml") @@ -265,6 +273,7 @@ def promote(root: Path, bindings: list[GoBinding], output: Path, github: GitHub, if new_tags: # All new module versions become available together. Never move a tag. git(root, "push", "--atomic", "origin", *("refs/tags/" + tag for tag in new_tags)) + time.sleep(TAG_SETTLE_SECONDS) for binding in bindings: release = releases[binding.tag] or github.create(binding, source) existing = {asset["name"] for asset in release["assets"]} diff --git a/tooling/extension-bindings/ci/test_publish.py b/tooling/extension-bindings/ci/test_publish.py index 767fd36..0349cab 100644 --- a/tooling/extension-bindings/ci/test_publish.py +++ b/tooling/extension-bindings/ci/test_publish.py @@ -12,6 +12,7 @@ import yaml +import publish from publish import (SUFFIXES, asset_paths, check_discovery, checksum_text, git, ordered_targets, preflight, promote) from build_extensions_site import go_page @@ -55,6 +56,9 @@ def setUp(self) -> None: summary = patch.dict("os.environ", {"GITHUB_STEP_SUMMARY": ""}) summary.start() self.addCleanup(summary.stop) + sleep = patch.object(publish.time, "sleep") + self.sleep = sleep.start() + self.addCleanup(sleep.stop) temporary = tempfile.TemporaryDirectory(prefix="binding-publication-test-") self.addCleanup(temporary.cleanup) self.work = Path(temporary.name) @@ -146,10 +150,14 @@ def test_publish_and_retry_reuse_identical_tags_and_assets(self): for binding in self.bindings: self.assertIn(binding.tag, refs) self.assertFalse(self.github.release(binding.tag)["draft"]) + # New tags get a minute before anything asks Go's servers for them. + self.sleep.assert_called_once_with(publish.TAG_SETTLE_SECONDS) uploads = self.github.uploads promote(self.root, self.bindings, self.output, self.github, False) self.assertEqual(self.github.uploads, uploads) self.assertEqual(git(self.root, "ls-remote", "origin"), refs) + # A retry pushes no tag, so it does not wait. + self.sleep.assert_called_once() def test_interrupted_upload_can_resume_without_rebuilding(self): self.github.fail_once = True