mirror of
https://github.com/anthropics/claude-cookbooks.git
synced 2025-10-06 01:00:28 +03:00
Remove nbqa in favor of ruff's native Jupyter support (v0.6.0+). Replace papermill with nbconvert due to uv dependency resolution issues. Also remove S105/S106 ignores to enforce better security practices. - Update pyproject.toml to use ruff v0.12.12 with native notebook support - Replace papermill with nbconvert for notebook execution - Remove nbqa from all dependencies and pre-commit hooks - Update GitHub Actions workflows to use ruff directly - Remove hardcoded password ignores for better security - Update documentation to reflect simplified setup - Add dummy package structure for hatchling build system 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
98 lines
3.0 KiB
YAML
98 lines
3.0 KiB
YAML
name: Notebook Quality Check
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'skills/**/*.ipynb'
|
|
- 'pyproject.toml'
|
|
- 'uv.lock'
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'skills/**/*.ipynb'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
validate-notebooks:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version: ['3.11', '3.12']
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
with:
|
|
enable-cache: true
|
|
cache-dependency-glob: "uv.lock"
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
run: uv python install ${{ matrix.python-version }}
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
uv sync --frozen --all-extras
|
|
|
|
- name: Check notebooks are clean
|
|
run: |
|
|
uv run nbstripout --verify skills/**/*.ipynb || \
|
|
(echo "❌ Notebooks contain outputs. Run 'nbstripout skills/**/*.ipynb' locally" && exit 1)
|
|
|
|
- name: Lint with Ruff
|
|
run: |
|
|
uv run ruff check skills/ --show-fixes
|
|
uv run ruff format skills/ --check
|
|
|
|
- name: Validate notebook structure
|
|
run: |
|
|
uv run python scripts/validate_notebooks.py
|
|
|
|
- name: Check model usage
|
|
run: |
|
|
uv run python scripts/check_models.py
|
|
|
|
# Only run API tests on main branch or for maintainers (costs money)
|
|
- name: Execute notebooks (API Testing)
|
|
if: |
|
|
github.event_name == 'push' ||
|
|
github.event.pull_request.author_association == 'MEMBER' ||
|
|
github.event.pull_request.author_association == 'OWNER'
|
|
env:
|
|
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
run: |
|
|
for notebook in skills/*/guide.ipynb; do
|
|
echo "📓 Testing: $notebook"
|
|
# Use nbconvert to execute notebooks
|
|
uv run jupyter nbconvert --to notebook \
|
|
--execute "$notebook" \
|
|
--ExecutePreprocessor.kernel_name=python3 \
|
|
--ExecutePreprocessor.timeout=120 \
|
|
--stdout > /dev/null \
|
|
|| echo "⚠️ Failed: $notebook"
|
|
done
|
|
|
|
# Mock testing for external contributors
|
|
- name: Execute notebooks (Mock Testing)
|
|
if: |
|
|
github.event_name == 'pull_request' &&
|
|
github.event.pull_request.author_association != 'MEMBER' &&
|
|
github.event.pull_request.author_association != 'OWNER'
|
|
run: |
|
|
echo "🔒 Running in mock mode for external contributor"
|
|
|
|
for notebook in skills/*/guide.ipynb; do
|
|
echo "📓 Validating structure: $notebook"
|
|
uv run python -m nbformat.validator.validate "$notebook"
|
|
done
|
|
|
|
- name: Upload test outputs
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: notebook-test-outputs-py${{ matrix.python-version }}
|
|
path: test_outputs/
|
|
retention-days: 7 |