Skip to content
Open
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
8 changes: 4 additions & 4 deletions tests/unit/test_registry_platform_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ async def test_startup_sync_schedules_artifact_for_resolved_version(

mock_result = SimpleNamespace(
version=SimpleNamespace(id=uuid.uuid4()),
version_string="1.0.0.dev20260522140000",
version_string="1.0.0+collision.20260522140000.123456",
num_actions=0,
actions=[],
)
Expand All @@ -480,7 +480,7 @@ async def test_startup_sync_schedules_artifact_for_resolved_version(
await _sync_as_leader(session, "1.0.0")

schedule_build.assert_called_once_with(
"1.0.0.dev20260522140000",
"1.0.0+collision.20260522140000.123456",
promote_version_id=None,
expected_current_version_id=None,
)
Expand Down Expand Up @@ -584,7 +584,7 @@ async def test_promote_after_artifact_build_promotes_collision_version(
)
collision_version = PlatformRegistryVersion(
repository_id=repo.id,
version="1.2.3.dev20260522140000",
version="1.2.3+collision.20260522140000.123456",
manifest=_make_manifest(["test.action_v2"]),
tarball_uri="s3://test/collision.tar.gz",
)
Expand All @@ -596,7 +596,7 @@ async def test_promote_after_artifact_build_promotes_collision_version(

await _promote_platform_registry_version_after_artifact_build(
session,
target_version="1.2.3.dev20260522140000",
target_version="1.2.3+collision.20260522140000.123456",
version_id=collision_version.id,
artifact_uri="s3://test/collision.tar.gz",
expected_current_version_id=old_version.id,
Expand Down
28 changes: 27 additions & 1 deletion tests/unit/test_registry_sync_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from types import SimpleNamespace

import pytest
from packaging.version import Version
from sqlalchemy import delete
from sqlalchemy.ext.asyncio import AsyncSession
from temporalio.client import WorkflowFailureError
Expand Down Expand Up @@ -162,7 +163,7 @@ async def fake_build_and_upload_artifacts(

assert first.version.version == "1.2.3"
assert first.version.id != second.version.id
assert second.version.version.startswith("1.2.3.dev")
assert second.version.version.startswith("1.2.3+collision.")
# Re-syncing unchanged content should reuse the active collision version.
assert third.version.id == second.version.id
assert repo.current_version_id == second.version.id
Expand All @@ -172,6 +173,31 @@ async def fake_build_and_upload_artifacts(
assert len(versions) == 2


@pytest.mark.parametrize(
"base_version",
[
"1.2.3",
"1.2.3.post1",
"1.2.3-beta.1",
"1.2.3-alpha.1",
"1.2.3+registry.1",
],
)
def test_generate_collision_version_preserves_release_suffixes(
base_version: str,
mocker,
) -> None:
service = RegistrySyncService(mocker.Mock(spec=AsyncSession), role=mocker.Mock())

collision_version = service._generate_collision_version(base_version)

if "+" in base_version:
assert collision_version.startswith(f"{base_version}.collision.")
else:
assert collision_version.startswith(f"{base_version}+collision.")
Version(collision_version)


@pytest.mark.anyio
async def test_platform_builtin_sync_reuses_existing_artifact_objects(
mocker,
Expand Down
6 changes: 4 additions & 2 deletions tracecat/registry/sync/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,12 @@ async def _resolve_sync_version(
return version, None

def _generate_collision_version(self, base_version: str) -> str:
"""Generate a unique dev version for same-version manifest changes."""
"""Append a unique local collision label without changing the release."""
suffix = datetime.now(UTC).strftime("%Y%m%d%H%M%S%f")
tiebreaker = cast(int, uuid.uuid4().int) % 1_000_000
return f"{base_version}.dev{suffix}{tiebreaker:06d}"
collision_label = f"collision.{suffix}.{tiebreaker:06d}"
separator = "." if "+" in base_version else "+"
return f"{base_version}{separator}{collision_label}"

def _build_validation_failure_message(
self,
Expand Down
Loading