Skip to content

Commit 6efab8f

Browse files
authored
Merge pull request #146 from bsipocz/add_tox
ENH: add tox.ini to generize test setup
2 parents e0b0d6a + 466e6b4 commit 6efab8f

File tree

5 files changed

+60
-14
lines changed

5 files changed

+60
-14
lines changed

.github/workflows/notebooks.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ jobs:
1717
max-parallel: 12
1818
matrix:
1919
os: [Ubuntu-20.04, macOS-latest]
20-
python-version: [3.8, 3.9, "3.10"]
20+
include:
21+
- python-version: '3.8'
22+
toxenv: py38-test-oldestdeps
23+
24+
- python-version: '3.9'
25+
toxenv: py39-test
26+
27+
- python-version: '3.10'
28+
toxenv: py310-test-devdeps
2129

2230
steps:
2331
- uses: actions/checkout@v3
@@ -27,18 +35,7 @@ jobs:
2735
python-version: ${{ matrix.python-version }}
2836

2937
- name: Install dependencies
30-
run: |
31-
python -m pip install -r site/requirements.txt -r requirements.txt
32-
python -m pip list
38+
run: python -m pip install --upgrade tox
3339

3440
- name: Test with nbval
35-
run: |
36-
python -m pip install pytest nbval
37-
find content/ -name "*.md" -exec jupytext --to notebook {} \;
38-
# TODO: find better way to exclude notebooks from test
39-
rm content/tutorial-deep-reinforcement-learning-with-pong-from-pixels.ipynb
40-
rm content/pairing.ipynb
41-
rm content/tutorial-style-guide.ipynb
42-
rm content/tutorial-nlp-from-scratch.ipynb
43-
# Test notebook execution
44-
pytest --nbval-lax --durations=10 content/
41+
run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,6 @@ site/notebooks/*
9797
content/mooreslaw_regression*
9898
content/tutorial-x-ray-image-processing/xray_image.gif
9999
content/video
100+
content/*ipynb
101+
content/tutorial-nlp-from-scratch/parameters.npy
102+
content/tutorial-nlp-from-scratch/*ipynb

ignore_testing

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
content/tutorial-deep-reinforcement-learning-with-pong-from-pixels.md
2+
content/pairing.md
3+
content/tutorial-style-guide.md
4+
content/tutorial-nlp-from-scratch.md

test_requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest
2+
nbval

tox.ini

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[tox]
2+
envlist =
3+
py{38,39,310}-test{,-oldestdeps,-devdeps,-predeps}{,-buildhtml}
4+
requires =
5+
pip >= 19.3.1
6+
7+
[testenv]
8+
9+
description = run tests
10+
11+
deps =
12+
# We use these files to specify all the dependencies, and below we override
13+
# versions for specific testing schenarios
14+
-rtest_requirements.txt
15+
-rsite/requirements.txt
16+
-rrequirements.txt
17+
18+
# TODO: add the oldest supported versions of all the dependencies here
19+
# oldestdeps: numpy==1.18
20+
# oldestdeps: matplotlib==3.1.2
21+
# oldestdeps: scipy==1.4
22+
23+
commands =
24+
devdeps: pip install -U --pre --only-binary :all: -i https://pypi.anaconda.org/scipy-wheels-nightly/simple numpy
25+
devdeps: pip install -U --pre --only-binary :all: -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy
26+
devdeps: pip install -U --pre --only-binary :all: -i https://pypi.anaconda.org/scipy-wheels-nightly/simple matplotlib
27+
28+
pip freeze
29+
30+
# Ignore testing the tutorials listed in ignore_testing file
31+
!buildhtml: bash -c 'find content -name "*.md" | grep -vf ignore_testing | xargs jupytext --to notebook '
32+
33+
!buildhtml: pytest --nbval-lax --durations=10 content/
34+
buildhtml: make -C site/ SPHINXOPTS="-nWT --keep-going" html
35+
36+
pip_pre =
37+
predeps: true
38+
!predeps: false
39+
40+
skip_install = true

0 commit comments

Comments
 (0)