Skip to content

Commit

Permalink
Merge pull request #50 from tbirdso/add-notebook-check
Browse files Browse the repository at this point in the history
ENH: Add Python Jupyter Notebook testing procedure
  • Loading branch information
tbirdso authored Jan 5, 2023
2 parents 55b88c4 + a79a8ed commit e63df7a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-test-package-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ on:
required: false
type: string
default: '["_2_28-x64","2014-x64","_2_28-aarch64"]'
test-notebooks:
description: 'Option to test Jupyter Notebooks in examples/ directory with applied changes'
required: false
type: boolean
default: false
secrets:
pypi_password:
required: false # Packages will not be uploaded to PyPI if not set
Expand Down Expand Up @@ -197,6 +202,50 @@ jobs:
name: WindowsWheel3.${{ matrix.python-version-minor }}
path: dist/*.whl

test-linux-notebooks:
if: inputs.test-notebooks
needs:
- build-linux-py
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install build dependencies
shell: bash
run: |
if [[ -f requirements.txt ]]; then
python -m pip install -r requirements.txt
elif [[ -f ./binder/requirements.txt ]]; then
python -m pip install -r ./binder/requirements.txt
fi
python -m pip install pytest nbmake
- name: Download Python Package Artifacts
uses: actions/download-artifact@v3
with:
name: LinuxWheel310

- name: Install Python Package Artifact
run: |
ls .
wheel_name_full=`(find . -name "*cp310-manylinux_2_28_x86_64.whl")`
echo "wheel_name_full ${wheel_name_full}"
# extract wheel name which may be an abbreviation of the module name
# ex. ./itk_splitcomponents-cp310..._64.whl -> itk-splitcomponents
wheel_name_prefix=`(echo ${wheel_name_full} | cut -d'-' -f1 | cut -d'/' -f2 | sed -e 's/_/-/g')`
echo "wheel_name_prefix ${wheel_name_prefix}"
python -m pip uninstall ${wheel_name_prefix} -y
python -m pip install ${wheel_name_full}
- name: Test notebooks
run: |
pytest --nbmake --nbmake-timeout=30000 examples/*.ipynb
publish-python-packages-to-pypi:
needs:
- build-linux-py
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,18 @@ to direct workflow execution.
manylinux-platforms: '["_2_28-x64","2014-x64","_2_28-aarch64"]'
```

- `test-notebooks`: Boolean option to test Jupyter Notebook examples located in the
`examples/` directory of the external module. A `requirements.txt` file
should be provided in either the external module root or `binder/` directories
to indicate notebook prerequisites for testing. Default value is `false`, notebook
tests may be enabled for a repository containing notebook examples by setting
the value to `true`.

```yaml
with:
test-notebooks: true
```

## Contributing

Community contributions to `ITKRemoteModuleBuildTestPackageAction` are welcome!
Expand Down

0 comments on commit e63df7a

Please sign in to comment.