|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright (C) 2026 Marco Fortina |
| 3 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + |
| 5 | +set -euo pipefail |
| 6 | + |
| 7 | +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 8 | +cd "${ROOT}" |
| 9 | + |
| 10 | +python - <<'PY' |
| 11 | +from __future__ import annotations |
| 12 | +
|
| 13 | +from pathlib import Path |
| 14 | +import re |
| 15 | +import yaml |
| 16 | +
|
| 17 | +failures: list[str] = [] |
| 18 | +
|
| 19 | +index_path = Path("examples/runbooks/RUNBOOK_INDEX.md") |
| 20 | +index_text = index_path.read_text(encoding="utf-8") |
| 21 | +indexed = { |
| 22 | + match.group("file"): int(match.group("count")) |
| 23 | + for match in re.finditer( |
| 24 | + r"\| `(?P<file>runbooks/[^`]+[.]check[.]yaml)` \| [^|]+ \| (?P<count>\d+) \|", |
| 25 | + index_text, |
| 26 | + ) |
| 27 | +} |
| 28 | +actual = {} |
| 29 | +for runbook_path in sorted(Path("examples/runbooks/runbooks").glob("*.check.yaml")): |
| 30 | + data = yaml.safe_load(runbook_path.read_text(encoding="utf-8")) |
| 31 | + count = sum( |
| 32 | + 1 |
| 33 | + for task in data.get("tasks", []) |
| 34 | + for step in task.get("steps", []) |
| 35 | + for _ in step.get("substeps", []) |
| 36 | + ) |
| 37 | + actual[f"runbooks/{runbook_path.name}"] = count |
| 38 | +if indexed != actual: |
| 39 | + failures.append( |
| 40 | + "examples/runbooks/RUNBOOK_INDEX.md is stale: " |
| 41 | + f"missing={sorted(set(actual) - set(indexed))} " |
| 42 | + f"extra={sorted(set(indexed) - set(actual))} " |
| 43 | + f"stale={sorted(name for name in set(actual) & set(indexed) if actual[name] != indexed[name])}" |
| 44 | + ) |
| 45 | +
|
| 46 | +plugin_index = Path("docs/plugins/index.md").read_text(encoding="utf-8") |
| 47 | +listed_plugins = set(re.findall(r"^([a-z][a-z0-9_]*(?:[.][a-z][a-z0-9_]*)+)$", plugin_index, flags=re.MULTILINE)) |
| 48 | +from automax.core.engine import AutomaxEngine |
| 49 | +actual_plugins = set(AutomaxEngine().plugin_registry.names()) |
| 50 | +if listed_plugins != actual_plugins: |
| 51 | + failures.append( |
| 52 | + "docs/plugins/index.md plugin list is stale: " |
| 53 | + f"missing={sorted(actual_plugins - listed_plugins)} " |
| 54 | + f"extra={sorted(listed_plugins - actual_plugins)}" |
| 55 | + ) |
| 56 | +
|
| 57 | +mkdocs = Path("mkdocs.yml").read_text(encoding="utf-8") |
| 58 | +for path in sorted(Path("docs/guides").glob("*.md")): |
| 59 | + nav = path.as_posix().removeprefix("docs/") |
| 60 | + if nav not in mkdocs: |
| 61 | + failures.append(f"mkdocs.yml does not include guide: {nav}") |
| 62 | +
|
| 63 | +pack_dir = Path("examples/runtime-packs") |
| 64 | +required_packs = {"package-only.env", "debian-like.env", "redhat-like.env", "privileged-vm.env"} |
| 65 | +actual_packs = {path.name for path in pack_dir.glob("*.env")} |
| 66 | +if required_packs - actual_packs: |
| 67 | + failures.append(f"missing runtime pack env files: {sorted(required_packs - actual_packs)}") |
| 68 | +
|
| 69 | +for pack in sorted(pack_dir.glob("*.env")): |
| 70 | + text = pack.read_text(encoding="utf-8") |
| 71 | + if "AUTOMAX_RUNTIME_PACK_STEPS" not in text: |
| 72 | + failures.append(f"{pack}: missing AUTOMAX_RUNTIME_PACK_STEPS") |
| 73 | +
|
| 74 | +if failures: |
| 75 | + for failure in failures: |
| 76 | + print(f"ERROR: {failure}") |
| 77 | + raise SystemExit(1) |
| 78 | +print("Example and documentation indexes OK") |
| 79 | +PY |
0 commit comments