|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + validate: |
| 11 | + name: Validate agent files |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Count agents |
| 17 | + run: | |
| 18 | + TOTAL=$(find . -path './.github' -prune -o -path './scripts' -prune -o -path './examples' -prune -o -path './integrations' -prune -o -name '*.md' -print | grep -c '/') |
| 19 | + echo "Total agent files: $TOTAL" |
| 20 | +
|
| 21 | + - name: Check frontmatter format |
| 22 | + run: | |
| 23 | + ERRORS=0 |
| 24 | + while IFS= read -r file; do |
| 25 | + # Skip non-agent files |
| 26 | + case "$file" in |
| 27 | + ./README*|./CONTRIBUTING*|./UPSTREAM*|./AGENT-LIST*|./CODE_OF_CONDUCT*|./.github/*|./scripts/*|./examples/*|./integrations/*|./docs/*) continue ;; |
| 28 | + esac |
| 29 | +
|
| 30 | + # Check frontmatter exists |
| 31 | + if ! head -1 "$file" | grep -q '^---'; then |
| 32 | + echo "::error file=$file::Missing frontmatter (no opening ---)" |
| 33 | + ERRORS=$((ERRORS + 1)) |
| 34 | + continue |
| 35 | + fi |
| 36 | +
|
| 37 | + # Check required fields |
| 38 | + FRONTMATTER=$(sed -n '/^---$/,/^---$/p' "$file" | head -20) |
| 39 | + for field in name description; do |
| 40 | + if ! echo "$FRONTMATTER" | grep -q "^${field}:"; then |
| 41 | + echo "::warning file=$file::Missing recommended field: $field" |
| 42 | + fi |
| 43 | + done |
| 44 | + done < <(find . -path './.github' -prune -o -path './scripts' -prune -o -path './examples' -prune -o -path './integrations' -prune -o -path './node_modules' -prune -o -name '*.md' -print | grep '/') |
| 45 | +
|
| 46 | + if [ $ERRORS -gt 0 ]; then |
| 47 | + echo "::error::$ERRORS file(s) have frontmatter errors" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + echo "All agent files validated successfully" |
| 51 | +
|
| 52 | + - name: Check for broken internal links |
| 53 | + run: | |
| 54 | + ERRORS=0 |
| 55 | + # Check README references to agent files |
| 56 | + grep -oP '\[.*?\]\(((?!http)[^)]+\.md)\)' README.md | grep -oP '\(([^)]+)\)' | tr -d '()' | while read -r link; do |
| 57 | + if [ ! -f "$link" ]; then |
| 58 | + echo "::error file=README.md::Broken link: $link" |
| 59 | + ERRORS=$((ERRORS + 1)) |
| 60 | + fi |
| 61 | + done |
| 62 | + exit $ERRORS |
0 commit comments