Skip to content

Repository files navigation

🛠️ Verify Jupyter Notebooks

Validates Jupyter Notebooks with pytest and nbmake.

python-notebook-test-action

Usage Example

steps:
- name: "Verify Jupyter Notebooks"uses: lfreleng-actions/python-notebook-test-action@mainwith:
python_version: "${{ env.python_version }}"

Inputs

Variable NameRequiredDefaultDescription
PYTHON_VERSIONTruePython version used to run tests
PERMIT_FAILFalseFalseContinue even when one or more tests fails
PATH_PREFIXFalseDirectory location containing Python project code
PARALLEL_TESTSFalseFalseParallel pytest/nbmake processes
NBMAKE_KERNELFalseFalseForce nbmake to use a specific kernel
INSTALL_KERNELFalseFalseInstall custom kernel before running tests
PYTEST_FLAGSFalse--no-covPytest flags; coverage reports disabled by default

Implementation Details

Refer to the following Python tool documentation: nbmake

Coverage Reports

Notebook tests and coverage reports may not play nicely together. Coverage reports are setup in the pyproject.toml file. Certain options may cause Notebook tests to fail. For this reason, coverage reports are not generated by default through explicit flags/options sent to the pytest command. You can override this behaviour (and enable coverage reports) by setting the relevant "pytest_flags" action/input to a null/empty string.

Notes

A wildcard search pattern under the PATH_PREFIX locates notebooks to test:

path_prefix/**/*ipynb

If this fails to locate any files, then the action will fail.

Parallel tests can speed up execution when large/complex notebooks are present.

Enabling INSTALL_KERNEL will invoke the following command before tests run:

python -m ipykernel install --user --name [NBMAKE_KERNEL]

In this instance, you must set NBMAKE_KERNEL otherwise the action will fail.

About

Uses pytest to run Jupyter Notebook tests

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors