|
| 1 | +name: Validate Plugin Structure |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + validate: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Validate JSON syntax |
| 16 | + run: | |
| 17 | + echo "Validating JSON files..." |
| 18 | + errors=0 |
| 19 | + for f in $(find . -name "*.json" -not -path "./node_modules/*"); do |
| 20 | + if ! jq empty "$f" 2>/dev/null; then |
| 21 | + echo "Invalid JSON: $f" |
| 22 | + errors=$((errors + 1)) |
| 23 | + fi |
| 24 | + done |
| 25 | + if [ "$errors" -gt 0 ]; then |
| 26 | + echo "$errors JSON file(s) have syntax errors" |
| 27 | + exit 1 |
| 28 | + fi |
| 29 | + echo "All JSON files valid" |
| 30 | +
|
| 31 | + - name: Validate plugin structure |
| 32 | + run: | |
| 33 | + echo "Checking required files..." |
| 34 | + errors=0 |
| 35 | +
|
| 36 | + for plugin_dir in plugins/*/; do |
| 37 | + name=$(basename "$plugin_dir") |
| 38 | + echo "Validating plugin: $name" |
| 39 | +
|
| 40 | + # Check required manifest |
| 41 | + if [ ! -f "$plugin_dir/.claude-plugin/plugin.json" ]; then |
| 42 | + echo " Missing: .claude-plugin/plugin.json" |
| 43 | + errors=$((errors + 1)) |
| 44 | + else |
| 45 | + # Validate name field exists |
| 46 | + plugin_name=$(jq -r '.name // empty' "$plugin_dir/.claude-plugin/plugin.json") |
| 47 | + if [ -z "$plugin_name" ]; then |
| 48 | + echo " Missing 'name' field in plugin.json" |
| 49 | + errors=$((errors + 1)) |
| 50 | + fi |
| 51 | + fi |
| 52 | +
|
| 53 | + # Check recommended files |
| 54 | + [ ! -f "$plugin_dir/README.md" ] && echo " Warning: Missing README.md" |
| 55 | + done |
| 56 | +
|
| 57 | + # Check marketplace manifest |
| 58 | + if [ ! -f ".claude-plugin/marketplace.json" ]; then |
| 59 | + echo "Missing: .claude-plugin/marketplace.json" |
| 60 | + errors=$((errors + 1)) |
| 61 | + fi |
| 62 | +
|
| 63 | + # Check repo-level files |
| 64 | + [ ! -f "LICENSE" ] && echo "Warning: Missing LICENSE" |
| 65 | + [ ! -f "README.md" ] && echo "Warning: Missing README.md" |
| 66 | + [ ! -f "SECURITY.md" ] && echo "Warning: Missing SECURITY.md" |
| 67 | +
|
| 68 | + if [ "$errors" -gt 0 ]; then |
| 69 | + echo "$errors validation error(s) found" |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | + echo "All validations passed" |
| 73 | +
|
| 74 | + - name: Check MCP endpoint reachability |
| 75 | + run: | |
| 76 | + for plugin_dir in plugins/*/; do |
| 77 | + if [ -f "$plugin_dir/.mcp.json" ]; then |
| 78 | + urls=$(jq -r '.. | .url? // empty' "$plugin_dir/.mcp.json" 2>/dev/null) |
| 79 | + for url in $urls; do |
| 80 | + echo "Checking: $url" |
| 81 | + status=$(curl -sf -o /dev/null -w "%{http_code}" --max-time 10 "$url" 2>/dev/null || echo "000") |
| 82 | + if [ "$status" = "000" ]; then |
| 83 | + echo " Warning: $url is unreachable (may require auth)" |
| 84 | + else |
| 85 | + echo " Reachable (HTTP $status)" |
| 86 | + fi |
| 87 | + done |
| 88 | + fi |
| 89 | + done |
0 commit comments