314dc03b0d
Moves the orchestrator into bot_bottle/orchestrator/ so one install gets everything. Entry point is now `python -m bot_bottle.orchestrator run`. - Add bot_bottle/orchestrator/ with all 14 modules (verbatim move; internal imports were already relative, so no changes inside orchestrator modules) - Rewrite bootstrap.py: remove the lazy bot_bottle import guard, use direct relative imports from ..contrib.* - Add bot_bottle/contrib/forge/base.py: ScopedForge (read-anywhere / write-scoped) - Add bot_bottle/contrib/gitea/client.py: GiteaClient + GiteaForge (urllib.request only) - Add bot_bottle/contrib/gitea/forge_state.py: ForgeState + SqliteForgeStateStore - Add tests/unit/orchestrator/ (82 tests: 63 migrated + 19 new for contrib modules) Closes #321
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
"""CLI entry point: `python -m bot_bottle.orchestrator <command>`.
|
|
|
|
Commands:
|
|
run start the webhook server + watchdog + done-signal relay
|
|
status print the tracked runs (issue -> slug, status)
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
|
|
from .config import Config
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
parser = argparse.ArgumentParser(prog="python -m bot_bottle.orchestrator")
|
|
sub = parser.add_subparsers(dest="command", required=True)
|
|
sub.add_parser("run", help="start the webhook server, watchdog, and relay")
|
|
sub.add_parser("status", help="list tracked runs")
|
|
args = parser.parse_args(argv)
|
|
|
|
config = Config.from_env()
|
|
|
|
if args.command == "run":
|
|
from . import bootstrap # pylint: disable=import-outside-toplevel
|
|
|
|
print(
|
|
f"orchestrator listening on "
|
|
f"http://{config.webhook_host}:{config.webhook_port}/webhook",
|
|
file=sys.stderr,
|
|
)
|
|
bootstrap.run(config)
|
|
return 0
|
|
|
|
if args.command == "status":
|
|
from .bootstrap import ( # pylint: disable=import-outside-toplevel
|
|
BotBottleStateStore,
|
|
)
|
|
|
|
store = BotBottleStateStore(config.db_path)
|
|
for r in store.all():
|
|
pr = f"PR#{r.pr_number}" if r.pr_number else "-"
|
|
print(f"{r.owner}/{r.repo}#{r.issue_number}\t{r.slug}\t{r.status}\t{pr}")
|
|
return 0
|
|
|
|
return 2
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|