| set -euo pipefail | |
| ROOT=${1:-/data/adaptai/platform/dbops} | |
| rc=0 | |
| py='import sys, yaml, pathlib\nrc=0\nfor p in pathlib.Path(sys.argv[1]).rglob("*.y*ml"):\n try:\n yaml.safe_load(open(p))\n except Exception as e:\n print(f"YAML error: {p}: {e}")\n rc=1\nprint(rc); sys.exit(rc)' | |
| if python3 - << PY 2>/dev/null; then | |
| import yaml | |
| print('ok') | |
| PY | |
| then | |
| echo "[lint] Using PyYAML" | |
| python3 - << PY "$ROOT" | |
| $py | |
| PY | |
| rc=$? | |
| else | |
| echo "[lint] PyYAML not available; basic syntax check only" | |
| # Fallback: ensure files are non-empty and have key: value structure | |
| while IFS= read -r -d '' f; do | |
| head -n1 "$f" >/dev/null || { echo "Empty: $f"; rc=1; } | |
| done < <(find "$ROOT" -type f -name "*.y*ml" -print0) | |
| fi | |
| exit $rc | |