Skip to content

Commit

Permalink
add github action for notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Jan 13, 2025
1 parent a4eee56 commit d0529ab
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/test-notebooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
tutorials:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install packages
run: |
sudo apt-get install -y rename
python -m pip install --upgrade pip wheel setuptools
python -m pip install -r requirements/tutorials.txt
python -m pip list
- name: Prepare notebooks
run: |
# go into tutorial location
cd tutorials
# convert each notebook into a python file
jupyter nbconvert --to script *.ipynb
# rename the files so they are found by pytest: add 'test' at the beginning
rename 's/(.*)\.py/test $1.py/' *
# rename the files so they are found by pytest: change spaces to underscores
rename 's/ /_/g' test*
# modify each file by adding one level of indentation to each line
sed -i 's/^/ /' test*.py
# modify each file by adding 'def test_func():' at the top
sed -i '1s;^;def test_func():\n;' test*.py
- name: Test tutorial notebooks
run: |
# run pytest ONLY on the tutorials
cd tutorials
pytest --color=yes
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: "3.13"

- name: Install packages
run: |
Expand Down

0 comments on commit d0529ab

Please sign in to comment.