|
| 1 | +name: Validate Plugin |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main, develop] |
| 8 | + |
| 9 | +jobs: |
| 10 | + validate-structure: |
| 11 | + name: Validate Plugin Structure |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Validate plugin.json |
| 17 | + run: | |
| 18 | + echo "Checking plugin.json exists and is valid JSON..." |
| 19 | + python3 -c " |
| 20 | + import json, sys |
| 21 | + with open('.claude-plugin/plugin.json') as f: |
| 22 | + data = json.load(f) |
| 23 | + required = ['name', 'version', 'description', 'author', 'license'] |
| 24 | + missing = [k for k in required if k not in data] |
| 25 | + if missing: |
| 26 | + print(f'Missing required fields: {missing}') |
| 27 | + sys.exit(1) |
| 28 | + print(f'Plugin: {data[\"name\"]} v{data[\"version\"]}') |
| 29 | + print('plugin.json is valid') |
| 30 | + " |
| 31 | +
|
| 32 | + - name: Validate command frontmatter |
| 33 | + run: | |
| 34 | + echo "Checking all commands have valid YAML frontmatter..." |
| 35 | + errors=0 |
| 36 | + for f in commands/*.md; do |
| 37 | + if ! head -1 "$f" | grep -q "^---$"; then |
| 38 | + echo "ERROR: $f missing frontmatter delimiter" |
| 39 | + errors=$((errors + 1)) |
| 40 | + fi |
| 41 | + if ! grep -q "^description:" "$f"; then |
| 42 | + echo "ERROR: $f missing description field" |
| 43 | + errors=$((errors + 1)) |
| 44 | + fi |
| 45 | + done |
| 46 | + echo "Checked $(ls commands/*.md | wc -l) commands" |
| 47 | + if [ $errors -gt 0 ]; then |
| 48 | + echo "Found $errors errors" |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | + echo "All commands valid" |
| 52 | +
|
| 53 | + - name: Validate agent frontmatter |
| 54 | + run: | |
| 55 | + echo "Checking all agents have valid frontmatter..." |
| 56 | + errors=0 |
| 57 | + for f in agents/*.md; do |
| 58 | + if ! head -1 "$f" | grep -q "^---$"; then |
| 59 | + echo "ERROR: $f missing frontmatter delimiter" |
| 60 | + errors=$((errors + 1)) |
| 61 | + fi |
| 62 | + for field in name description tools model; do |
| 63 | + if ! grep -q "^${field}:" "$f"; then |
| 64 | + echo "ERROR: $f missing $field field" |
| 65 | + errors=$((errors + 1)) |
| 66 | + fi |
| 67 | + done |
| 68 | + done |
| 69 | + echo "Checked $(ls agents/*.md | wc -l) agents" |
| 70 | + if [ $errors -gt 0 ]; then |
| 71 | + echo "Found $errors errors" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | + echo "All agents valid" |
| 75 | +
|
| 76 | + - name: Validate YAML templates |
| 77 | + run: | |
| 78 | + echo "Checking all templates are valid YAML..." |
| 79 | + python3 -c " |
| 80 | + import yaml, glob, sys |
| 81 | + errors = 0 |
| 82 | + for f in sorted(glob.glob('templates/*.yaml')): |
| 83 | + try: |
| 84 | + with open(f) as fh: |
| 85 | + data = yaml.safe_load(fh) |
| 86 | + if data.get('apiVersion') != 'astromesh/v1': |
| 87 | + print(f'ERROR: {f} wrong apiVersion: {data.get(\"apiVersion\")}') |
| 88 | + errors += 1 |
| 89 | + if data.get('kind') != 'Agent': |
| 90 | + print(f'ERROR: {f} wrong kind: {data.get(\"kind\")}') |
| 91 | + errors += 1 |
| 92 | + if not data.get('metadata', {}).get('name'): |
| 93 | + print(f'ERROR: {f} missing metadata.name') |
| 94 | + errors += 1 |
| 95 | + print(f' {f}: {data[\"metadata\"][\"name\"]} - OK') |
| 96 | + except Exception as e: |
| 97 | + print(f'ERROR: {f} invalid YAML: {e}') |
| 98 | + errors += 1 |
| 99 | + print(f'Checked {len(glob.glob(\"templates/*.yaml\"))} templates') |
| 100 | + if errors: |
| 101 | + sys.exit(1) |
| 102 | + print('All templates valid') |
| 103 | + " |
| 104 | +
|
| 105 | + - name: Validate file completeness |
| 106 | + run: | |
| 107 | + echo "Checking expected files exist..." |
| 108 | + errors=0 |
| 109 | + expected_commands="leia create deploy status logs test templates config bootstrap teardown" |
| 110 | + for cmd in $expected_commands; do |
| 111 | + if [ ! -f "commands/${cmd}.md" ]; then |
| 112 | + echo "ERROR: missing commands/${cmd}.md" |
| 113 | + errors=$((errors + 1)) |
| 114 | + fi |
| 115 | + done |
| 116 | +
|
| 117 | + expected_agents="leia-interpreter leia-architect leia-operator leia-tester leia-doctor" |
| 118 | + for agent in $expected_agents; do |
| 119 | + if [ ! -f "agents/${agent}.md" ]; then |
| 120 | + echo "ERROR: missing agents/${agent}.md" |
| 121 | + errors=$((errors + 1)) |
| 122 | + fi |
| 123 | + done |
| 124 | +
|
| 125 | + expected_schemas="astromesh-v1-agent nexus-api whatsapp-config orchestration-patterns" |
| 126 | + for schema in $expected_schemas; do |
| 127 | + if [ ! -f "schemas/${schema}.md" ]; then |
| 128 | + echo "ERROR: missing schemas/${schema}.md" |
| 129 | + errors=$((errors + 1)) |
| 130 | + fi |
| 131 | + done |
| 132 | +
|
| 133 | + for f in .claude-plugin/plugin.json README.md LICENSE CHANGELOG.md; do |
| 134 | + if [ ! -f "$f" ]; then |
| 135 | + echo "ERROR: missing $f" |
| 136 | + errors=$((errors + 1)) |
| 137 | + fi |
| 138 | + done |
| 139 | +
|
| 140 | + if [ $errors -gt 0 ]; then |
| 141 | + echo "Found $errors missing files" |
| 142 | + exit 1 |
| 143 | + fi |
| 144 | + echo "All expected files present" |
| 145 | +
|
| 146 | + validate-docs: |
| 147 | + name: Validate Documentation |
| 148 | + runs-on: ubuntu-latest |
| 149 | + steps: |
| 150 | + - uses: actions/checkout@v4 |
| 151 | + |
| 152 | + - name: Check documentation files exist |
| 153 | + run: | |
| 154 | + expected_docs="architecture commands-reference agents-guide templates-guide configuration whatsapp-setup troubleshooting" |
| 155 | + errors=0 |
| 156 | + for doc in $expected_docs; do |
| 157 | + if [ ! -f "docs/${doc}.md" ]; then |
| 158 | + echo "ERROR: missing docs/${doc}.md" |
| 159 | + errors=$((errors + 1)) |
| 160 | + fi |
| 161 | + done |
| 162 | +
|
| 163 | + expected_tutorials="first-agent business-templates multi-tenant advanced-patterns" |
| 164 | + for tut in $expected_tutorials; do |
| 165 | + if [ ! -f "docs/tutorials/${tut}.md" ]; then |
| 166 | + echo "ERROR: missing docs/tutorials/${tut}.md" |
| 167 | + errors=$((errors + 1)) |
| 168 | + fi |
| 169 | + done |
| 170 | +
|
| 171 | + if [ $errors -gt 0 ]; then |
| 172 | + exit 1 |
| 173 | + fi |
| 174 | + echo "All documentation files present" |
| 175 | +
|
| 176 | + - name: Check for broken internal links |
| 177 | + run: | |
| 178 | + echo "Checking for broken internal markdown links..." |
| 179 | + errors=0 |
| 180 | + for f in $(find docs -name "*.md") README.md; do |
| 181 | + # Extract relative links like [text](path.md) or [text](../path.md) |
| 182 | + links=$(grep -oP '\]\((?!http)(?!#)([^)]+\.md)\)' "$f" 2>/dev/null | sed 's/\](\(.*\))/\1/' || true) |
| 183 | + dir=$(dirname "$f") |
| 184 | + for link in $links; do |
| 185 | + resolved="$dir/$link" |
| 186 | + if [ ! -f "$resolved" ]; then |
| 187 | + echo "WARNING: $f references $link (resolved: $resolved) - not found" |
| 188 | + fi |
| 189 | + done |
| 190 | + done |
| 191 | + echo "Link check complete" |
0 commit comments