feat(standards): add Drone CI standard (PyPI package + Docker deployment)
Document the two `.drone.yml` shapes used across the org, derived from the repos: - Type A `python-lib.yaml`: build-and-publish-pypi + backfill-pypi-from-tags - Type B `service-docker.yaml`: build-and-deploy-service + build-and-deploy-site - add reference page `10_drone_pipelines` - vendor `src/templates/drone/` into the MCP bundle (`drone.json`) - expose `registry://drone` + `list_drone_templates` / `get_drone_template` - wire `build.py` to vendor drone templates; rebuild nav/index (14 modules)
This commit is contained in:
77
build.py
77
build.py
@@ -336,6 +336,82 @@ def build_templates(folder: Path, dry_run: bool = False) -> None:
|
||||
f"({len(manifest['components'])} components)")
|
||||
|
||||
|
||||
# ── Drone standard bundle ─────────────────────────────────────────────────────
|
||||
|
||||
# The two CI shapes shipped in ``src/templates/drone``. There are exactly two
|
||||
# types of ``.drone.yml`` in the org: a Python package (private PyPI) and a
|
||||
# Docker deployment (build / push / run). See standards "10_drone_pipelines".
|
||||
_DRONE_COMPONENTS: list[dict[str, str]] = [
|
||||
{"kind": "drone-pypi", "path": "python-lib.yaml", "placeholder": "",
|
||||
"description": "Drone pipeline: build + publish a Python package to the private PyPI index."},
|
||||
{"kind": "drone-service", "path": "service-docker.yaml", "placeholder": "",
|
||||
"description": "Drone pipeline: build, push, and deploy a Docker service or site."},
|
||||
]
|
||||
|
||||
|
||||
def build_drone_manifest(template_root: Path) -> dict[str, object]:
|
||||
"""Describe every CI template in the vendored drone standard.
|
||||
|
||||
Args:
|
||||
template_root (Path): The vendored ``templates/drone`` directory.
|
||||
|
||||
Returns:
|
||||
dict[str, object]: Manifest with the two component entries.
|
||||
"""
|
||||
components: list[dict[str, str]] = []
|
||||
for entry in _DRONE_COMPONENTS:
|
||||
rel = entry["path"]
|
||||
if not (template_root / rel).exists():
|
||||
raise SystemExit(f"[ERR] drone template missing: {rel}")
|
||||
components.append({
|
||||
"kind": entry["kind"],
|
||||
"path": rel,
|
||||
"placeholder": entry["placeholder"],
|
||||
"description": entry["description"],
|
||||
})
|
||||
return {
|
||||
"project": "standards",
|
||||
"template": "templates/drone",
|
||||
"types": ["pypi", "docker"],
|
||||
"components": components,
|
||||
}
|
||||
|
||||
|
||||
def build_drone_templates(folder: Path, dry_run: bool = False) -> None:
|
||||
"""Vendor ``folder/src/templates/drone`` into ``<name>/mcp/templates/drone``.
|
||||
|
||||
Ships the two ``.drone.yml`` shapes (PyPI package, Docker deployment) in the
|
||||
MCP bundle so an agent can pull the exact CI file, and emits ``drone.json``
|
||||
describing them.
|
||||
|
||||
Args:
|
||||
folder (Path): The hub folder owning ``src/templates/drone``.
|
||||
dry_run (bool): Print the plan without executing.
|
||||
"""
|
||||
name = folder.name
|
||||
src = folder / "src" / "templates" / "drone"
|
||||
if not src.is_dir():
|
||||
return
|
||||
out_dir = folder / "mcp" / "templates" / "drone"
|
||||
if dry_run:
|
||||
print(f"[DRN] {name} {src.relative_to(ROOT)}/** -> {out_dir.relative_to(ROOT)}/**")
|
||||
return
|
||||
|
||||
if out_dir.exists():
|
||||
shutil.rmtree(out_dir)
|
||||
out_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copytree(
|
||||
src, out_dir,
|
||||
ignore=shutil.ignore_patterns("__pycache__", "*.pyc", ".git"),
|
||||
)
|
||||
manifest = build_drone_manifest(out_dir)
|
||||
(folder / "mcp" / "drone.json").write_text(
|
||||
json.dumps(manifest, indent=2, ensure_ascii=False), encoding="utf-8"
|
||||
)
|
||||
print(f"[DRN] {name} drone templates vendored to {out_dir.relative_to(ROOT)}/ "
|
||||
f"({len(manifest['components'])} components)")
|
||||
|
||||
|
||||
# ── CLI ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -355,6 +431,7 @@ def main() -> None:
|
||||
for folder in folders:
|
||||
build_bundle(folder, dry_run=args.dry_run)
|
||||
build_templates(folder, dry_run=args.dry_run)
|
||||
build_drone_templates(folder, dry_run=args.dry_run)
|
||||
build_html(folder, dry_run=args.dry_run)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user