|  | 
|  | 1 | +name: Notebook Quality Check | 
|  | 2 | + | 
|  | 3 | +on: | 
|  | 4 | +  pull_request: | 
|  | 5 | +    paths: | 
|  | 6 | +      - 'skills/**/*.ipynb' | 
|  | 7 | +      - 'pyproject.toml' | 
|  | 8 | +      - 'uv.lock' | 
|  | 9 | +  push: | 
|  | 10 | +    branches: [main] | 
|  | 11 | +    paths: | 
|  | 12 | +      - 'skills/**/*.ipynb' | 
|  | 13 | + | 
|  | 14 | +permissions: | 
|  | 15 | +  contents: read | 
|  | 16 | +  pull-requests: write | 
|  | 17 | + | 
|  | 18 | +jobs: | 
|  | 19 | +  validate-notebooks: | 
|  | 20 | +    runs-on: ubuntu-latest | 
|  | 21 | +     | 
|  | 22 | +    steps: | 
|  | 23 | +      - uses: actions/checkout@v4 | 
|  | 24 | +       | 
|  | 25 | +      - name: Install uv | 
|  | 26 | +        uses: astral-sh/setup-uv@v4 | 
|  | 27 | +        with: | 
|  | 28 | +          enable-cache: true | 
|  | 29 | +          cache-dependency-glob: "uv.lock" | 
|  | 30 | +       | 
|  | 31 | +      - name: Set up Python 3.11 | 
|  | 32 | +        run: uv python install 3.11 | 
|  | 33 | +       | 
|  | 34 | +      - name: Install dependencies | 
|  | 35 | +        run: | | 
|  | 36 | +          uv sync --frozen --all-extras | 
|  | 37 | +       | 
|  | 38 | +      - name: Lint notebooks with Ruff | 
|  | 39 | +        run: | | 
|  | 40 | +          uv run ruff check skills/**/*.ipynb --show-fixes || true | 
|  | 41 | +          uv run ruff format skills/**/*.ipynb --check || true | 
|  | 42 | +       | 
|  | 43 | +      - name: Validate notebook structure | 
|  | 44 | +        run: | | 
|  | 45 | +          uv run python scripts/validate_notebooks.py | 
|  | 46 | +       | 
|  | 47 | +      # Only run API tests on main branch or for maintainers (costs money) | 
|  | 48 | +      - name: Execute notebooks (API Testing) | 
|  | 49 | +        if: | | 
|  | 50 | +          github.event_name == 'push' ||  | 
|  | 51 | +          github.event.pull_request.author_association == 'MEMBER' || | 
|  | 52 | +          github.event.pull_request.author_association == 'OWNER' | 
|  | 53 | +        env: | 
|  | 54 | +          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | 
|  | 55 | +        run: | | 
|  | 56 | +          mkdir -p test_outputs | 
|  | 57 | +          for notebook in skills/*/guide.ipynb; do | 
|  | 58 | +            echo "📓 Testing: $notebook" | 
|  | 59 | +            output_name=$(basename $(dirname "$notebook")) | 
|  | 60 | +            # Use nbconvert to execute notebooks and save outputs | 
|  | 61 | +            uv run jupyter nbconvert --to notebook \ | 
|  | 62 | +              --execute "$notebook" \ | 
|  | 63 | +              --ExecutePreprocessor.kernel_name=python3 \ | 
|  | 64 | +              --ExecutePreprocessor.timeout=120 \ | 
|  | 65 | +              --output "test_outputs/${output_name}_executed.ipynb" \ | 
|  | 66 | +              --output-dir=. \ | 
|  | 67 | +              || echo "⚠️  Failed: $notebook" | 
|  | 68 | +          done | 
|  | 69 | +       | 
|  | 70 | +      # Mock testing for external contributors | 
|  | 71 | +      - name: Execute notebooks (Mock Testing) | 
|  | 72 | +        if: | | 
|  | 73 | +          github.event_name == 'pull_request' &&  | 
|  | 74 | +          github.event.pull_request.author_association != 'MEMBER' && | 
|  | 75 | +          github.event.pull_request.author_association != 'OWNER' | 
|  | 76 | +        run: | | 
|  | 77 | +          echo "🔒 Running in mock mode for external contributor" | 
|  | 78 | +           | 
|  | 79 | +          for notebook in skills/*/guide.ipynb; do | 
|  | 80 | +            echo "📓 Validating structure: $notebook" | 
|  | 81 | +            uv run python -m nbformat.validator "$notebook" | 
|  | 82 | +          done | 
|  | 83 | +       | 
|  | 84 | +      - name: Upload test outputs | 
|  | 85 | +        if: always() | 
|  | 86 | +        uses: actions/upload-artifact@v4 | 
|  | 87 | +        with: | 
|  | 88 | +          name: notebook-test-outputs | 
|  | 89 | +          path: test_outputs/ | 
|  | 90 | +          retention-days: 7 | 
0 commit comments