Skip to content

Commit 8a098be

Browse files
Merge pull request #184 from WilliamK112/ci/notebook-smoke
ci: smoke-test notebooks
2 parents e0bf7ab + 30146ed commit 8a098be

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

‎.github/workflows/notebooks.yml‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Notebook smoke
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "notebooks/**"
8+
- "src/freshdata/**"
9+
- "pyproject.toml"
10+
- ".github/workflows/notebooks.yml"
11+
pull_request:
12+
paths:
13+
- "notebooks/**"
14+
- "src/freshdata/**"
15+
- "pyproject.toml"
16+
- ".github/workflows/notebooks.yml"
17+
workflow_dispatch:
18+
19+
concurrency:
20+
group: notebooks-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
smoke:
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 10
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
persist-credentials: false
34+
35+
- uses: actions/setup-python@v5
36+
with:
37+
python-version: "3.12"
38+
cache: pip
39+
40+
- name: Install notebook smoke dependencies
41+
run: |
42+
python -m pip install --upgrade pip
43+
pip install -e . nbclient nbformat ipykernel
44+
python -m ipykernel install --user --name freshdata-smoke
45+
46+
- name: Validate notebook JSON
47+
run: |
48+
python - <<'PY'
49+
from pathlib import Path
50+
51+
import nbformat
52+
53+
notebooks = sorted(Path("notebooks").rglob("*.ipynb"))
54+
if not notebooks:
55+
raise SystemExit("no notebooks found")
56+
57+
for path in notebooks:
58+
notebook = nbformat.read(path, as_version=4)
59+
nbformat.validate(notebook)
60+
print(f"validated {path}")
61+
PY
62+
63+
# Keep optional ML/model notebooks out of required CI. The quickstart is
64+
# deliberately dependency-light and exercises the installed package.
65+
- name: Execute quickstart notebook
66+
run: |
67+
python - <<'PY'
68+
from pathlib import Path
69+
70+
import nbformat
71+
from nbclient import NotebookClient
72+
73+
path = Path("notebooks/01_quickstart.ipynb")
74+
notebook = nbformat.read(path, as_version=4)
75+
NotebookClient(
76+
notebook,
77+
timeout=120,
78+
kernel_name="freshdata-smoke",
79+
resources={"metadata": {"path": str(path.parent)}},
80+
).execute()
81+
print(f"executed {path}")
82+
PY

0 commit comments

Comments
 (0)