feat: phase 2 — am lab (benchmark N agents) + plugins d'événements (contrat JSON)
- #62: am lab --agents a,b --task <f> — séquentiel ou --parallel, capture durée/exit/sortie/coût estimé, rapport comparatif tableau + --json stable, tâches versionnables dans <state>/lab/ (--list), rejouables à l'identique - #75: plugins/ sous state_dir, déclenchés sur on_install/on_start/on_stop/ on_update (App::emit), contrat JSON stdin/stdout, timeout configurable, échec non bloquant, garde anti-récursion AM_PLUGINS_RUNNING, am plugins + am plugins --test <name> (CI), exemples notify + ci-webhook - intégration REPL (parse, complétion, bannière, is_am_command), help, tips, man pages (am-lab.1, am-plugins.1), README, ROADMAP (26/27), v0.5.4 - 334 tests verts (309 + 25) closes #62 closes #75
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Plugin exemple (issue #75) : poste les événements install/update vers un
|
||||
webhook CI. Si la variable d'environnement CI_WEBHOOK_URL n'est pas définie,
|
||||
le plugin répond ok sans rien faire (échec non bloquant, jamais fatal).
|
||||
|
||||
Exemple : CI_WEBHOOK_URL=https://hooks.example.com/am-ci am update --all
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib.request
|
||||
|
||||
|
||||
def main() -> int:
|
||||
ev = json.load(sys.stdin)
|
||||
url = os.environ.get("CI_WEBHOOK_URL")
|
||||
if not url:
|
||||
print(json.dumps({"ok": True, "message": "CI_WEBHOOK_URL non définie — rien à faire"}))
|
||||
return 0
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
data=json.dumps(ev).encode(),
|
||||
headers={"Content-Type": "application/json"},
|
||||
method="POST",
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=5) as resp:
|
||||
status = resp.status
|
||||
except Exception as exc: # échec non bloquant : warning seulement
|
||||
print(json.dumps({"ok": False, "error": f"webhook: {exc}"}))
|
||||
return 0
|
||||
print(json.dumps({"ok": True, "message": f"webhook {status}"}))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user