Skip to content

ENH: add tox.ini to generize test setup #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ jobs:
max-parallel: 12
matrix:
os: [Ubuntu-20.04, macOS-latest]
python-version: [3.8, 3.9, "3.10"]
include:
- python-version: '3.8'
toxenv: py38-test-oldestdeps

- python-version: '3.9'
toxenv: py39-test

- python-version: '3.10'
toxenv: py310-test-devdeps

steps:
- uses: actions/checkout@v2
Expand All @@ -27,18 +35,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install -r site/requirements.txt -r requirements.txt
python -m pip list
run: python -m pip install --upgrade tox

- name: Test with nbval
run: |
python -m pip install pytest nbval
find content/ -name "*.md" -exec jupytext --to notebook {} \;
# TODO: find better way to exclude notebooks from test
rm content/tutorial-deep-reinforcement-learning-with-pong-from-pixels.ipynb
rm content/pairing.ipynb
rm content/tutorial-style-guide.ipynb
rm content/tutorial-nlp-from-scratch.ipynb
# Test notebook execution
pytest --nbval-lax --durations=10 content/
run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ site/notebooks/*
content/mooreslaw_regression*
content/tutorial-x-ray-image-processing/xray_image.gif
content/video
content/*ipynb
content/tutorial-nlp-from-scratch/parameters.npy
content/tutorial-nlp-from-scratch/*ipynb
4 changes: 4 additions & 0 deletions ignore_testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
content/tutorial-deep-reinforcement-learning-with-pong-from-pixels.md
content/pairing.md
content/tutorial-style-guide.md
content/tutorial-nlp-from-scratch.md
2 changes: 2 additions & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest
nbval
40 changes: 40 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[tox]
envlist =
py{38,39,310}-test{,-oldestdeps,-devdeps,-predeps}{,-buildhtml}
requires =
pip >= 19.3.1

[testenv]

description = run tests

deps =
# We use these files to specify all the dependencies, and below we override
# versions for specific testing schenarios
-rtest_requirements.txt
-rsite/requirements.txt
-rrequirements.txt

# TODO: add the oldest supported versions of all the dependencies here
# oldestdeps: numpy==1.18
# oldestdeps: matplotlib==3.1.2
# oldestdeps: scipy==1.4

commands =
devdeps: pip install -U --pre --only-binary :all: -i https://pypi.anaconda.org/scipy-wheels-nightly/simple numpy
devdeps: pip install -U --pre --only-binary :all: -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy
devdeps: pip install -U --pre --only-binary :all: -i https://pypi.anaconda.org/scipy-wheels-nightly/simple matplotlib

pip freeze

# Ignore testing the tutorials listed in ignore_testing file
!buildhtml: bash -c 'find content -name "*.md" | grep -vf ignore_testing | xargs jupytext --to notebook '

!buildhtml: pytest --nbval-lax --durations=10 content/
buildhtml: make -C site/ SPHINXOPTS="-nWT --keep-going" html

pip_pre =
predeps: true
!predeps: false

skip_install = true