diff --git a/.github/workflows/test-notebooks.yml b/.github/workflows/test-notebooks.yml new file mode 100644 index 0000000..c9e959a --- /dev/null +++ b/.github/workflows/test-notebooks.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5218794..285d985 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: |