Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tooling/extension-bindings/ci/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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"]}
Expand Down
8 changes: 8 additions & 0 deletions tooling/extension-bindings/ci/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down