mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
* Add `cli.deploy.test` module to orchestrate compose-based CI deploy tests * Support server per-app runs (including run_after dependencies) and workstation selection * Add optional image build flags (--no-cache, --missing) and stack retention on failure * Simplify `scripts/tests/deploy.sh` to a thin wrapper that forwards args to the Python runner https://chatgpt.com/share/695f9e22-6e9c-800f-9a50-65f553619af2
71 lines
1.9 KiB
Python
71 lines
1.9 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import os
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
|
|
from .runner import run_test_plan
|
|
|
|
|
|
def main(argv: Optional[list[str]] = None) -> int:
|
|
parser = argparse.ArgumentParser(
|
|
prog="python -m cli.deploy.test",
|
|
description="CI deploy test orchestrator (compose-based).",
|
|
)
|
|
parser.add_argument(
|
|
"--type",
|
|
required=True,
|
|
choices=["server", "workstation"],
|
|
help="Deploy type.",
|
|
)
|
|
parser.add_argument(
|
|
"--distro",
|
|
default=os.environ.get("INFINITO_DISTRO", "arch"),
|
|
choices=["arch", "debian", "ubuntu", "fedora", "centos"],
|
|
help="Target distro (also used for compose image tag).",
|
|
)
|
|
parser.add_argument(
|
|
"--no-cache",
|
|
action="store_true",
|
|
help="Rebuild compose image with --no-cache.",
|
|
)
|
|
parser.add_argument(
|
|
"--missing",
|
|
action="store_true",
|
|
help="Build only if missing (skip build if image exists).",
|
|
)
|
|
parser.add_argument(
|
|
"--app",
|
|
default=None,
|
|
help="Run server deploy test only for this single application_id (plus run_after deps).",
|
|
)
|
|
parser.add_argument(
|
|
"--logs-dir",
|
|
default="logs",
|
|
help="Directory for log files (default: logs).",
|
|
)
|
|
parser.add_argument(
|
|
"--keep-stack-on-failure",
|
|
action="store_true",
|
|
help="Do not tear down compose stack on failure.",
|
|
)
|
|
|
|
args = parser.parse_args(argv)
|
|
|
|
# Ensure env is consistent with compose usage
|
|
os.environ["INFINITO_DISTRO"] = args.distro
|
|
|
|
logs_dir = Path(args.logs_dir).resolve()
|
|
logs_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
return run_test_plan(
|
|
deploy_type=args.type,
|
|
distro=args.distro,
|
|
no_cache=args.no_cache,
|
|
missing_only=args.missing,
|
|
only_app=args.app,
|
|
logs_dir=logs_dir,
|
|
keep_stack_on_failure=args.keep_stack_on_failure,
|
|
)
|