|
| 1 | +--- |
| 2 | +name: CI |
| 3 | + |
| 4 | +'on': |
| 5 | + pull_request: |
| 6 | + types: [opened, synchronize, reopened, ready_for_review] |
| 7 | + push: |
| 8 | + branches: [dev, main] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ci-${{ github.event.pull_request.number || github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + pull-requests: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + validate: |
| 21 | + name: Validate |
| 22 | + runs-on: ubuntu-latest |
| 23 | + timeout-minutes: 15 |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Honor workflow kill switch |
| 31 | + run: | |
| 32 | + if [ -f .github/WORKFLOW_KILLSWITCH ]; then |
| 33 | + status=$(grep -E '^STATUS:' .github/WORKFLOW_KILLSWITCH | awk '{print $2}') |
| 34 | + if [ "$status" = "DISABLED" ]; then |
| 35 | + echo "::notice::Workflows disabled by .github/WORKFLOW_KILLSWITCH" |
| 36 | + exit 0 |
| 37 | + fi |
| 38 | + fi |
| 39 | +
|
| 40 | + - name: Validate branch name |
| 41 | + if: github.event_name == 'pull_request' && github.event.pull_request.base.ref != 'main' |
| 42 | + env: |
| 43 | + BRANCH: ${{ github.head_ref }} |
| 44 | + run: | |
| 45 | + # Feature branches PR into dev. Allowed prefixes cover conventional |
| 46 | + # types, automation bots, and Claude AI sessions. |
| 47 | + pattern='^(feat|fix|docs|chore|refactor|test|build|ci|perf|style|hotfix|release|claude|dependabot|renovate)/[a-z0-9][a-z0-9._/-]*$' |
| 48 | + if [[ "$BRANCH" =~ $pattern || "$BRANCH" == "dev" ]]; then |
| 49 | + echo "::notice::branch '$BRANCH' OK" |
| 50 | + else |
| 51 | + echo "::error::branch '$BRANCH' must match $pattern" |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Note release PR (skip naming + commitlint) |
| 56 | + if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' |
| 57 | + run: | |
| 58 | + echo "::notice::release PR (dev → main); branch naming and commitlint skipped" |
| 59 | +
|
| 60 | + - name: Set up Python |
| 61 | + uses: actions/setup-python@v5 |
| 62 | + with: |
| 63 | + python-version: '3.11' |
| 64 | + |
| 65 | + - name: Set up Node.js |
| 66 | + uses: actions/setup-node@v4 |
| 67 | + with: |
| 68 | + node-version: 20 |
| 69 | + |
| 70 | + - name: Install tooling |
| 71 | + run: | |
| 72 | + python -m pip install --upgrade pip |
| 73 | + pip install yamllint==1.35.1 check-jsonschema==0.28.4 \ |
| 74 | + PyYAML==6.0.2 jsonschema==4.23.0 |
| 75 | + shellcheck --version |
| 76 | +
|
| 77 | + - name: Validate commit messages |
| 78 | + if: github.event_name == 'pull_request' && github.event.pull_request.base.ref != 'main' |
| 79 | + env: |
| 80 | + BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 81 | + HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 82 | + run: | |
| 83 | + # Release PRs (dev → main) are squash-merged with a single clean |
| 84 | + # message, so commitlint is skipped above. Feature PRs to dev get |
| 85 | + # full validation. |
| 86 | + npm install --no-save --silent \ |
| 87 | + @commitlint/cli@18.6.0 @commitlint/config-conventional@18.6.0 |
| 88 | + npx commitlint --from "$BASE_SHA" --to "$HEAD_SHA" |
| 89 | +
|
| 90 | + - name: yamllint .github/workflows |
| 91 | + run: | |
| 92 | + yamllint -d '{extends: default, rules: {line-length: {max: 160}}}' \ |
| 93 | + .github/workflows |
| 94 | +
|
| 95 | + - name: Validate GitHub workflow schemas |
| 96 | + run: | |
| 97 | + for file in .github/workflows/*.yml; do |
| 98 | + # smart-sync uses projects_v2_item which isn't in the public schema |
| 99 | + if [[ "$file" != *"smart-sync.yml" ]]; then |
| 100 | + check-jsonschema --builtin-schema github-workflows "$file" |
| 101 | + fi |
| 102 | + done |
| 103 | +
|
| 104 | + - name: Validate skill / agent / command frontmatter |
| 105 | + run: python3 scripts/validate_frontmatter.py all |
| 106 | + |
| 107 | + - name: Verify @agent and @skill cross-references |
| 108 | + run: python3 scripts/check_agent_references.py |
| 109 | + |
| 110 | + - name: Verify documented counts match repo state |
| 111 | + run: python3 scripts/check_doc_counts.py |
| 112 | + |
| 113 | + - name: ShellCheck install/update/smoke scripts |
| 114 | + run: | |
| 115 | + # Severity=error blocks real bugs. SC2155/SC2115 style warnings |
| 116 | + # are tracked separately; bump severity after cleanup. |
| 117 | + shellcheck --severity=error \ |
| 118 | + scripts/install.sh scripts/update.sh scripts/smoke_install.sh |
| 119 | +
|
| 120 | + - name: Smoke-test install and update |
| 121 | + run: bash scripts/smoke_install.sh |
| 122 | + |
| 123 | + - name: Markdown internal-link check |
| 124 | + run: | |
| 125 | + npx --yes markdown-link-check@3.12.2 \ |
| 126 | + --config .markdown-link-check.json \ |
| 127 | + README.md CLAUDE.md NAVIGATION.md |
0 commit comments