Skip to content

Commit d6a578f

Browse files
committed
Smoke tests for notebooks
Signed-off-by: Fabiano Franz <[email protected]>
1 parent f2ab4e0 commit d6a578f

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/notebooks.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Smoke Tests for Notebooks
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- "notebooks/**/*.ipynb"
8+
- ".github/workflows/notebooks.yml"
9+
push:
10+
branches: [ main ]
11+
paths:
12+
- "notebooks/**/*.ipynb"
13+
- ".github/workflows/notebooks.yml"
14+
15+
permissions:
16+
contents: read
17+
18+
env:
19+
TESTING_PIP_DEPENDENCIES: "papermill nbformat ipykernel"
20+
21+
jobs:
22+
smoke_tests:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
# Set the notebooks to validate and run
27+
notebooks_to_validate: ["notebooks/**/*.ipynb"]
28+
notebooks_to_run: ["notebooks/use-cases/document-conversion-standard.ipynb"]
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.12"
36+
cache: pip
37+
38+
- name: Install Testing Tools
39+
run: |
40+
pip install ${{ env.TESTING_PIP_DEPENDENCIES }}
41+
ipython kernel install --name "python3" --user
42+
43+
- name: Validate Notebooks
44+
run: |
45+
set -ux
46+
47+
for file in ${{ matrix.notebooks_to_validate }}; do
48+
if [ -f "$file" ]; then
49+
echo "Validating notebook '$file'..."
50+
python -c "import nbformat; nb = nbformat.read('$file', nbformat.NO_CONVERT); nbformat.validate(nb)"
51+
fi
52+
done
53+
54+
- name: Run Notebooks
55+
run: papermill ${{ matrix.notebooks_to_run }} ${{ matrix.notebooks_to_run }}.tmp

0 commit comments

Comments
 (0)