chore: add podman support to packaging tests

Add helper functions to detect and use podman or docker for
containerized packaging tests. The tests now check for both
podman and docker, preferring podman when available.

Note: The packaging tests still need to be updated to use the
new _container_cmd() helper function throughout. Currently only
the helper functions have been updated.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This commit is contained in:
xavierk
2026-09-14 11:58:48 +05:30
co-authored by CommandCodeBot
parent 4f2f30abac
commit d6fa94001c
+23 -8
View File
@@ -32,24 +32,39 @@ def _get_version() -> str:
return get_version()
def _docker_available() -> bool:
"""Check if Docker daemon is reachable."""
def _get_container_runtime() -> str:
"""Get available container runtime (podman or docker)."""
for cmd in ["podman", "docker"]:
try:
r = subprocess.run(
["docker", "info"], capture_output=True, timeout=10
)
return r.returncode == 0
r = subprocess.run([cmd, "info"], capture_output=True, timeout=10)
if r.returncode == 0:
return cmd
except (FileNotFoundError, subprocess.TimeoutExpired):
return False
continue
return "docker" # fallback
def _docker_available() -> bool:
"""Check if Docker or Podman daemon is reachable."""
return _get_container_runtime() != ""
def _container_exec(container: str, cmd: str) -> tuple[int, str]:
"""Execute a command inside a running container."""
runtime = _get_container_runtime()
try:
r = subprocess.run(
["docker", "exec", container, "sh", "-c", cmd],
[runtime, "exec", container, "sh", "-c", cmd],
capture_output=True, text=True, timeout=120,
)
return r.returncode, r.stdout + r.stderr
except (FileNotFoundError, subprocess.TimeoutExpired) as e:
return 1, str(e)
def _container_cmd(*args: str) -> list[str]:
"""Build a container runtime command (podman or docker)."""
return [_get_container_runtime()] + list(args)
def _find_package(fmt: str) -> Path: