run notebooks #17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: run notebooks | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- dev | |
schedule: | |
- cron: "30 2 * * 4" # every thursday on 2:30am UTC | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.12"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Display Python version | |
run: python -c "import sys; print(sys.version)" | |
- name: Install dependencies | |
run: pip install jupyter nbconvert | |
- run: pip install -r requirements.txt | |
- name: Find notebooks | |
id: find-notebooks | |
run: | | |
find . -name "*.ipynb" > notebooks.txt | |
cat notebooks.txt | |
shell: bash | |
- name: Execute notebooks | |
run: | | |
cat notebooks.txt | while read -r notebook; do | |
jupyter nbconvert --to notebook --ExecutePreprocessor.kernel_name=python3 --execute --inplace "$notebook" | |
done | |
continue-on-error: false | |
shell: bash | |
- name: Check for errors | |
run: | | |
if grep "raise Exception(" *.ipynb; then | |
echo "Error found in notebook(s)." | |
exit 1 | |
else | |
echo "No errors found in notebooks." | |
fi | |
shell: bash |