Merge remote-tracking branch 'origin/main' into feature/store-i18n

# Conflicts:
#	scripts/lint/mermaid.sh
#	tests/unit/python/utils/docker/test_image_discovery_lifecycle.py
#	utils/docker/image/discovery.py
This commit is contained in:
kevinveenbirkenbach committed 2026-10-14 13:44:56 +02:00
commit 5e2a5fcc31
24 files changed
+593 -85

No files matched your search

@@ -1,5 +1,6 @@
from __future__ import annotations
import os
import tempfile
import unittest
from pathlib import Path
@@ -8,7 +9,7 @@ from utils.docker.image.discovery import iter_role_images, role_lifecycle
from utils.roles.mapping import ROLE_FILE_META_SERVICES
SUPPORTED = """---
engine:
demo:
image: libretranslate/libretranslate
version: v1.9.6
lifecycle: stable
@@ -18,7 +19,7 @@ helper:
"""
RETIRED = """---
store:
demo:
image: quay.io/minio/minio
version: RELEASE.2025-09-07T16-13-09Z
lifecycle: eol
@@ -28,24 +29,31 @@ client:
"""
UNSTAGED = """---
engine:
demo:
image: libretranslate/libretranslate
version: v1.9.6
"""
class TestImageDiscoveryLifecycle(unittest.TestCase):
def _images(self, services_yaml: str) -> set[str]:
def _images(self, services_yaml: str, *, relative: bool = False) -> set[str]:
"""Discover the images of one role written into a temporary repository.
Args:
services_yaml: the role's ``meta/services.yml``.
relative: pass the repository root relative to the working directory.
"""
with tempfile.TemporaryDirectory() as tmp:
services = Path(tmp) / "roles" / "web-app-demo" / ROLE_FILE_META_SERVICES
services.parent.mkdir(parents=True)
services.write_text(services_yaml, encoding="utf-8")
return {ref.service for ref in iter_role_images(Path(tmp))}
root = Path(os.path.relpath(tmp)) if relative else Path(tmp)
return {ref.service for ref in iter_role_images(root)}
def test_a_supported_role_yields_every_service(self) -> None:
self.assertEqual({"engine", "helper"}, self._images(SUPPORTED))
self.assertEqual({"demo", "helper"}, self._images(SUPPORTED))
def test_a_retired_role_yields_nothing(self) -> None:
def test_a_retired_role_yields_none_of_its_services(self) -> None:
"""Its upstream may withdraw the images; no deploy can reach them."""
self.assertEqual(set(), self._images(RETIRED))
@@ -54,7 +62,10 @@ class TestImageDiscoveryLifecycle(unittest.TestCase):
self.assertNotIn("client", self._images(RETIRED))
def test_a_role_that_names_no_stage_is_kept(self) -> None:
self.assertEqual({"engine"}, self._images(UNSTAGED))
self.assertEqual({"demo"}, self._images(UNSTAGED))
def test_a_relative_root_still_leaves_a_retired_role_out(self) -> None:
self.assertEqual(set(), self._images(RETIRED, relative=True))
class TestRoleLifecycle(unittest.TestCase):