-
Notifications
You must be signed in to change notification settings - Fork 5.5k
94 lines (80 loc) · 2.85 KB
/
Copy pathnotebook-quality.yml
File metadata and controls
94 lines (80 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Notebook Quality Check
on:
pull_request:
paths:
- 'skills/**/*.ipynb'
- 'pyproject.toml'
- 'uv.lock'
push:
branches: [main]
paths:
- 'skills/**/*.ipynb'
permissions:
contents: read
pull-requests: write
jobs:
validate-notebooks:
runs-on: ubuntu-latest
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 3.11
run: uv python install 3.11
- name: Install dependencies
run: |
uv sync --frozen --all-extras
- name: Lint notebooks with Ruff
run: |
uv run ruff check skills/**/*.ipynb --show-fixes || true
uv run ruff format skills/**/*.ipynb --check || true
- 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: |
mkdir -p test_outputs
for notebook in skills/*/guide.ipynb; do
echo "📓 Testing: $notebook"
output_name=$(basename $(dirname "$notebook"))
# Use nbconvert to execute notebooks and save outputs
uv run jupyter nbconvert --to notebook \
--execute "$notebook" \
--ExecutePreprocessor.kernel_name=python3 \
--ExecutePreprocessor.timeout=120 \
--output "test_outputs/${output_name}_executed.ipynb" \
--output-dir=. \
|| 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 "$notebook"
done
- name: Upload test outputs
if: always()
uses: actions/upload-artifact@v4
with:
name: notebook-test-outputs
path: test_outputs/
retention-days: 7