Testing notebooks #515
This file contains 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: Testing notebooks | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: '0 5 * * 1' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
max-parallel: 12 | |
matrix: | |
os: [Ubuntu-22.04, macOS-latest] | |
python-version: ["3.11", "3.12", "3.13"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Before install | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
sudo apt-get update | |
sudo apt-get install graphviz graphviz-dev | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
brew install graphviz pkg-config | |
fi | |
python3 -m venv ~/venv | |
source ~/venv/bin/activate | |
- name: Install dependencies | |
run: | | |
pip install -U pip | |
if [ "$RUNNER_OS" == "macOS" ]; then | |
pip install --config-settings="--global-option=build_ext" \ | |
--config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \ | |
--config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \ | |
pygraphviz | |
elif [ "$RUNNER_OS" == "Linux" ]; then | |
pip install pygraphviz | |
fi | |
pip install -r requirements.txt | |
pip list | |
- name: Lint with precommit | |
run: | | |
pip install pre-commit | |
find content/ -name "*.md" -exec jupytext --to notebook {} \; | |
# pre-commit wants files to be staged | |
find content/ -name "*.ipynb" -exec git add {} \; | |
pre-commit run --all-files --show-diff-on-failure --color always | |
- name: Test with nbval | |
run: | | |
find content/algorithms content/generators -name "*.md" -exec jupytext --to notebook {} \; | |
find content/algorithms content/generators -name "*.ipynb" -print | |
pip install pytest | |
pytest --nbval-lax --durations=25 content/algorithms content/generators |