Simplify Athena operator maintenance workflow

This commit is contained in:
Mikei386
2026-08-25 08:42:30 +02:00
parent fa9911eb3b
commit ac725416b8
11 changed files with 126 additions and 33 deletions
+17 -10
View File
@@ -310,12 +310,18 @@ def normalise_operation(operation: str, payload: dict[str, Any]) -> tuple[dict[s
message = str(payload.get("message", ""))
if not SAFE_COMMIT.fullmatch(message):
raise ValueError("invalid commit message")
status = run(["git", "status", "--short"], cwd=REPOSITORY, check=True)["output"].strip()
paths = payload.get("paths")
if not isinstance(paths, list) or not 1 <= len(paths) <= MAX_FILES:
raise ValueError("paths must contain 1..24 repository files")
selected = [str(safe_relative(str(path))) for path in paths]
if len(set(selected)) != len(selected):
raise ValueError("paths must be unique")
status = run(["git", "status", "--short", "--", *selected], cwd=REPOSITORY, check=True)["output"].strip()
if not status:
raise RuntimeError("repository has no changes to publish")
diff = run(["git", "diff", "--stat"], cwd=REPOSITORY, check=True)["output"]
preview = f"Commit message: {message}\n\nChanged and untracked files:\n{status}\n\nDiff summary:\n{diff}"
return {"message": message, "reviewed_status": status}, preview
raise RuntimeError("selected repository paths have no changes to publish")
diff = run(["git", "diff", "--stat", "--", *selected], cwd=REPOSITORY, check=True)["output"]
preview = f"Commit message: {message}\nSelected paths: {', '.join(selected)}\n\nSelected changes:\n{status}\n\nDiff summary:\n{diff}"
return {"message": message, "paths": selected, "reviewed_status": status}, preview
if operation == "model_download":
url = str(payload.get("url", ""))
parsed = urllib.parse.urlparse(url)
@@ -414,12 +420,13 @@ def execute_operation(ticket: str, operation: str, payload: dict[str, Any]) -> d
raise FileNotFoundError("versioned Open WebUI synchronisation script is missing")
return {"sync": run(["bash", str(installer)], cwd=STACK, timeout=1800, check=True)}
if operation == "git_publish":
current_status = run(["git", "status", "--short"], cwd=REPOSITORY, check=True)["output"].strip()
selected = payload["paths"]
current_status = run(["git", "status", "--short", "--", *selected], cwd=REPOSITORY, check=True)["output"].strip()
if current_status != payload["reviewed_status"]:
raise RuntimeError("repository changed after the Git publish preview")
run(["git", "add", "--all"], cwd=REPOSITORY, check=True)
run(["git", "diff", "--cached", "--check"], cwd=REPOSITORY, check=True)
commit = run(["git", "commit", "-m", payload["message"]], cwd=REPOSITORY, check=True)
raise RuntimeError("selected repository paths changed after the Git publish preview")
run(["git", "add", "--", *selected], cwd=REPOSITORY, check=True)
run(["git", "diff", "--cached", "--check", "--", *selected], cwd=REPOSITORY, check=True)
commit = run(["git", "commit", "-m", payload["message"], "--", *selected], cwd=REPOSITORY, check=True)
pushed = run(["git", "push", "origin", "HEAD:main"], cwd=REPOSITORY, timeout=300, check=True)
head = run(["git", "rev-parse", "HEAD"], cwd=REPOSITORY, check=True)["output"].strip()
(STACK / ".mike-ai-source-commit").write_text(head + "\n")