Skip to content

Matrix over test files. #483

Matrix over test files.

Matrix over test files. #483

Workflow file for this run

# Test that all the notebooks run properly. This is a sort of simple
# unit test. We don't assert that the notebooks produce any particuler
# expected results, but we at least know they keep running as we make
# changes to the underlying library.
name: nbmake
on:
push:
branches-ignore:
- main
jobs:
# List the notebooks
list-notebooks:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.notebook-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: notebook-matrix
run: echo "matrix=$(find notebooks -name "*.ipynb" | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
nbmake:
needs: list-notebooks
runs-on: ubuntu-latest
strategy:
matrix:
notebook: ${{ fromJson(needs.list-notebooks.outputs.matrix) }}
fail-fast: false
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: 3.12
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --extras=explore --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --extras=explore --no-interaction
#----------------------------------------------
# test run notebooks
#----------------------------------------------
- name: Test run notebook
run: |
source .venv/bin/activate
# pytest --junitxml=reports/nbmake/${{matrix.notebook-type}}/junit.xml --nbmake ${{matrix.notebook-dir}}/*.ipynb
# genbadge tests --name "${{matrix.notebook-type}} tests" -i reports/nbmake/${{matrix.notebook-type}}/junit.xml -o reports/nbmake/nbmake-${{matrix.notebook-type}}-badge.svg
pytest --nbmake "${{matrix.notebook}}"