|
| 1 | +name: Docs — Reference Drift Check |
| 2 | + |
| 3 | +# Fails a PR if the committed /website/docs/reference/ output disagrees |
| 4 | +# with what tools/generate_docs_reference.py would produce from the live |
| 5 | +# Python tool/resource registry. Contributors should regenerate locally: |
| 6 | +# |
| 7 | +# cd Server && uv run python ../tools/generate_docs_reference.py |
| 8 | +# |
| 9 | +# or install the pre-commit hook to make this automatic: |
| 10 | +# |
| 11 | +# tools/install-hooks.sh |
| 12 | + |
| 13 | +on: |
| 14 | + pull_request: |
| 15 | + branches: [beta, main] |
| 16 | + paths: |
| 17 | + - Server/src/services/tools/** |
| 18 | + - Server/src/services/resources/** |
| 19 | + - Server/src/services/registry/** |
| 20 | + - website/docs/reference/** |
| 21 | + - tools/generate_docs_reference.py |
| 22 | + - .github/workflows/docs-generate.yml |
| 23 | + push: |
| 24 | + branches: [beta] |
| 25 | + paths: |
| 26 | + - Server/src/services/tools/** |
| 27 | + - Server/src/services/resources/** |
| 28 | + - Server/src/services/registry/** |
| 29 | + - website/docs/reference/** |
| 30 | + - tools/generate_docs_reference.py |
| 31 | + - .github/workflows/docs-generate.yml |
| 32 | + workflow_dispatch: {} |
| 33 | + |
| 34 | +jobs: |
| 35 | + check: |
| 36 | + name: Check docs reference is fresh |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + persist-credentials: false |
| 43 | + |
| 44 | + - name: Install uv |
| 45 | + uses: astral-sh/setup-uv@v4 |
| 46 | + with: |
| 47 | + version: latest |
| 48 | + |
| 49 | + - name: Set up Python |
| 50 | + run: uv python install 3.10 |
| 51 | + |
| 52 | + - name: Sync Server deps |
| 53 | + working-directory: Server |
| 54 | + run: uv sync |
| 55 | + |
| 56 | + - name: Drift check |
| 57 | + working-directory: Server |
| 58 | + run: uv run python ../tools/generate_docs_reference.py --check |
| 59 | + |
| 60 | + - name: Tool-count sanity |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + # Match the decorator at start-of-line (skips imports and docstring mentions). |
| 64 | + decorator_count=$(grep -rhE "^@mcp_for_unity_tool\(" Server/src/services/tools/ | wc -l | tr -d ' ') |
| 65 | + # md_count excludes group landing pages (index.md) and the catalog root. |
| 66 | + md_count=$(find website/docs/reference/tools -name '*.md' -not -name 'index.md' | wc -l | tr -d ' ') |
| 67 | + echo "decorator_count=$decorator_count, md_count=$md_count" |
| 68 | + if [[ "$decorator_count" != "$md_count" ]]; then |
| 69 | + echo "Mismatch: $decorator_count @mcp_for_unity_tool decorators vs $md_count reference pages." >&2 |
| 70 | + echo "Run: cd Server && uv run python ../tools/generate_docs_reference.py" >&2 |
| 71 | + exit 1 |
| 72 | + fi |
0 commit comments