feat: consolidate legacy workflows into gyxx-flow

This commit is contained in:
2026-07-28 14:51:15 +08:00
commit c23b62a8c8
374 changed files with 132990 additions and 0 deletions
+85
View File
@@ -0,0 +1,85 @@
from __future__ import annotations
import io
import json
from datetime import date
from pathlib import Path
from gyxx_flow.catalog import WorkflowCatalog
from gyxx_flow.cli import main
from gyxx_flow.core.config import Settings
from gyxx_flow.scheduler import CurrentScheduledTask
from gyxx_flow.workflow import WorkflowDefinition
from gyxx_flow.workflow.registry import WorkflowRegistry
PROJECT_ROOT = Path(__file__).resolve().parents[1]
class FakeCurrentTaskProvider:
def __init__(self, tasks: list[CurrentScheduledTask]) -> None:
self.tasks = tasks
self.requested_path: str | None = None
def current_tasks(self, task_path: str) -> list[CurrentScheduledTask]:
self.requested_path = task_path
return self.tasks
def test_schedule_plan_cli_writes_inert_bundle_and_drift_report(tmp_path: Path) -> None:
provider = FakeCurrentTaskProvider([])
output = io.StringIO()
destination = tmp_path / "generated-plan"
settings = Settings(project_root=PROJECT_ROOT, data_root=tmp_path / "data")
exit_code = main(
[
"schedule",
"plan",
"--output",
str(destination),
"--start-date",
"2026-07-27",
"--python-executable",
str(PROJECT_ROOT / ".venv" / "Scripts" / "python.exe"),
],
settings=settings,
current_task_provider=provider,
stdout=output,
stderr=io.StringIO(),
)
assert exit_code == 0
payload = json.loads(output.getvalue())
assert payload["desired_count"] == 21
assert payload["applied"] is False
assert payload["drift_count"] == 21
assert provider.requested_path == "\\GYXX\\"
assert (destination / "install.ps1").is_file()
assert (destination / "drift.json").is_file()
assert json.loads((destination / "plan.json").read_text(encoding="utf-8"))[
"applied"
] is False
def test_scheduled_run_uses_shanghai_business_date_and_executes_registered_workflow(
monkeypatch, tmp_path: Path
) -> None:
catalog = WorkflowCatalog.load(PROJECT_ROOT / "config")
registry = WorkflowRegistry(catalog)
registry.register(WorkflowDefinition("product.daily", ()))
monkeypatch.setattr("gyxx_flow.cli._today_shanghai", lambda: date(2026, 7, 27))
output = io.StringIO()
exit_code = main(
["run", "product.daily", "--scheduled"],
registry=registry,
settings=Settings(project_root=PROJECT_ROOT, data_root=tmp_path),
stdout=output,
stderr=io.StringIO(),
)
assert exit_code == 0
payload = json.loads(output.getvalue())
assert payload["business_date"] == "2026-07-27"
assert payload["dry_run"] is False
assert payload["status"] == "success"