Files
devx/src/devx/molecule/platforms.py
T

49 lines
1.4 KiB
Python

"""Supported OS platform matrix for molecule tests.
Single source of truth for the platform list used by both:
- ``devx.molecule.distribute_molecule`` (CI parallel matrix)
- local sequential runners
Keeping this in a dedicated module avoids cross-imports between
dev tools and CI scripts.
"""
from __future__ import annotations
import json
from pathlib import Path
#: Default supported OS platform matrix.
#: Each entry maps a short name to (image, command).
#: Uses the project's pre-built molecule-test-base image with
#: ``sleep infinity`` (NOT systemd) to avoid cgroup v2 failures.
PLATFORMS: list[dict[str, str]] = [
{
"name": "ubuntu-2604",
"image": "git.oblachno.oblachno.fyi/oblachno/molecule-test-base:latest",
"command": "sleep infinity",
},
]
def load_platforms(platforms_file: str | Path | None = None) -> list[dict[str, str]]:
"""Load platforms from a JSON file, falling back to PLATFORMS.
Args:
platforms_file: Path to a JSON file with a list of platform dicts.
Each dict must have ``name``, ``image``, and ``command`` keys.
Returns:
List of platform dictionaries.
"""
if platforms_file is None:
return PLATFORMS
path = Path(platforms_file)
if not path.is_file():
return PLATFORMS
with path.open(encoding="utf-8") as f:
data = json.load(f)
if not isinstance(data, list) or not data:
return PLATFORMS
return data