mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-07 03:15:56 +00:00
The workspace workflow asked the distro SPOT two questions through embedded python one-liners: the matrix image list, and the distro behind a matrix entry. Give both a name -- distro_of_dev_runtime_image() as the counterpart to dev_runtime_image(), and a cli.meta.ci.dev_runtime module shaped like its image_ref neighbour. The empty-SPOT guard that protected the matrix from silently skipping every job moves along with it. No caller yet; the workflow switches over in the next commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""Answer the development-runtime matrix questions from the distro SPOT.
|
|
|
|
Exists so workflow steps can ask for the matrix, and for the distro behind a
|
|
matrix entry, without embedding a python one-liner per question.
|
|
|
|
python3 -m cli.meta.ci.dev_runtime images
|
|
python3 -m cli.meta.ci.dev_runtime distro --image fedora:latest
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import sys
|
|
|
|
from utils.distros import (
|
|
FILE_META_DISTROS,
|
|
dev_runtime_images,
|
|
distro_of_dev_runtime_image,
|
|
)
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
commands = parser.add_subparsers(dest="command", required=True)
|
|
commands.add_parser("images", help="Print the matrix images as a JSON array.")
|
|
distro = commands.add_parser(
|
|
"distro", help="Print the distro a matrix image belongs to."
|
|
)
|
|
distro.add_argument(
|
|
"--image", required=True, help="Matrix image, e.g. fedora:latest."
|
|
)
|
|
args = parser.parse_args(argv)
|
|
|
|
if args.command == "images":
|
|
images = list(dev_runtime_images())
|
|
if not images:
|
|
print(
|
|
f"{FILE_META_DISTROS} declares no dev runtime image; "
|
|
"an empty matrix would skip every workspace job silently",
|
|
file=sys.stderr,
|
|
)
|
|
return 1
|
|
print(json.dumps(images))
|
|
return 0
|
|
|
|
print(distro_of_dev_runtime_image(args.image))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|