diff --git a/scripts/sync_github_project.py b/scripts/sync_github_project.py index 7b93e561c30..47a9cf95e43 100644 --- a/scripts/sync_github_project.py +++ b/scripts/sync_github_project.py @@ -6,6 +6,7 @@ import re import subprocess import sys +import time import urllib.error import urllib.request from functools import cache @@ -212,6 +213,12 @@ def tags_containing(commit): """ if not re.fullmatch(r"[0-9a-f]{40}", commit): raise ValueError("Invalid implementation commit") + started = time.monotonic() + print( + f"Project sync: release ancestry start commit={commit[:12]}", + file=sys.stderr, + flush=True, + ) result = subprocess.run( ["git", "tag", "--contains", commit], cwd=ROOT, @@ -224,7 +231,14 @@ def tags_containing(commit): raise RuntimeError( "Cannot verify release tag ancestry; fetch full history and tags" ) - return frozenset(result.stdout.splitlines()) + tags = frozenset(result.stdout.splitlines()) + print( + f"Project sync: release ancestry complete commit={commit[:12]} tags={len(tags)} " + f"seconds={time.monotonic() - started:.2f}", + file=sys.stderr, + flush=True, + ) + return tags def delivery(content, current, linked, releases, mainline): diff --git a/tests/test_project_delivery.py b/tests/test_project_delivery.py index 7d9d8d7e43c..cc457668822 100644 --- a/tests/test_project_delivery.py +++ b/tests/test_project_delivery.py @@ -339,7 +339,10 @@ def git(*args): (root / "file").write_text("release three") git("commit", "-am", "release three") git("tag", "v3") - with patch.object(sync, "ROOT", root): + with ( + patch.object(sync, "ROOT", root), + patch("sys.stderr", new_callable=io.StringIO) as output, + ): sync.tag_names.cache_clear() sync.tags_containing.cache_clear() self.assertEqual(sync.tags_containing(base), {"v1", "v2", "v3"}) @@ -370,6 +373,11 @@ def git(*args): ], "v2", ) + self.assertIn("release ancestry start", output.getvalue()) + self.assertIn("release ancestry complete", output.getvalue()) + self.assertIn(f"commit={second[:12]}", output.getvalue()) + self.assertRegex(output.getvalue(), r"tags=\d+") + self.assertRegex(output.getvalue(), r"seconds=\d+\.\d{2}") def test_tag_containment_failure_fails_closed(self): sync.tags_containing.cache_clear()