From 3ee0c95611683daa95232d76acf454fd23c707f5 Mon Sep 17 00:00:00 2001 From: Mika Date: Wed, 28 Jan 2026 16:22:44 +0000 Subject: [PATCH] Add ci_report_hook/src/ci_report_hook/cli.py --- ci_report_hook/src/ci_report_hook/cli.py | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ci_report_hook/src/ci_report_hook/cli.py diff --git a/ci_report_hook/src/ci_report_hook/cli.py b/ci_report_hook/src/ci_report_hook/cli.py new file mode 100644 index 0000000..c0b5587 --- /dev/null +++ b/ci_report_hook/src/ci_report_hook/cli.py @@ -0,0 +1,46 @@ +import argparse +import sys +from ci_report_hook.core import record_ci_run + + +def main() -> None: + """CLI entrypoint for recording CI run reports.""" + parser = argparse.ArgumentParser( + description="Erfasst Laufdaten eines CI-Runs und speichert sie als Report-JSON." + ) + + parser.add_argument("--run-id", required=True, type=str, help="Eindeutiger Bezeichner des CI-Runs.") + parser.add_argument("--decision", required=True, type=str, choices=["PASS", "WARN", "FAIL"], help="Entscheidung: PASS, WARN oder FAIL.") + parser.add_argument("--margin", required=True, type=float, help="Abstand zur Entscheidungsgrenze als float.") + parser.add_argument("--flaky-flag", required=False, type=str, default="False", help="Boolesches Flag zur Instabilitätsmarkierung.") + parser.add_argument("--subset-flip-count", required=False, type=int, default=0, help="Anzahl Subset-Flips im CI-Run.") + parser.add_argument("--mischfenster-p95", required=False, type=float, default=0.0, help="95. Perzentil des Mischfensters als float.") + + args = parser.parse_args() + + # Convert inputs and validate + try: + flaky_flag_str = args.flaky_flag.strip().lower() + if flaky_flag_str in ("true", "1", "yes", "y"): + flaky_flag = True + elif flaky_flag_str in ("false", "0", "no", "n"): + flaky_flag = False + else: + raise ValueError(f"Ungültiger Wert für --flaky-flag: {args.flaky_flag}") + + record_ci_run( + run_id=args.run_id, + decision=args.decision, + margin=args.margin, + flaky_flag=flaky_flag, + subset_flip_count=args.subset_flip_count, + mischfenster_p95=args.mischfenster_p95, + ) + + except Exception as exc: + print(f"Fehler beim Erfassen des CI-Reports: {exc}", file=sys.stderr) + sys.exit(1) + + +if __name__ == "__main__": + main()