Skip to content

Commit 1b3e67a

Browse files
committed
CI: adding tox and testing
1 parent 7555564 commit 1b3e67a

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tox.ini

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[tox]
2+
envlist =
3+
py{311, 312, 313}-test{,-oldestdeps,-devdeps,-predeps}{,-buildhtml}
4+
requires =
5+
pip >= 19.3.1
6+
7+
[testenv]
8+
9+
description = run tests
10+
11+
setenv =
12+
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
13+
14+
passenv = CI, CIRCLECI, GITHUB_EVENT_NAME, GITHUB_EVENT_PATH
15+
16+
deps =
17+
# We use these files to specify all the dependencies, and below we override
18+
# versions for specific testing schenarios
19+
-rrequirements.txt
20+
#-rsite_requirements.txt
21+
#-r.binder/requirements.txt
22+
23+
# Notebooks may set minimums for some dependencies, the others are set for a supported minimum
24+
# following e.g. SPEC0 or some other considerations.
25+
oldestdeps: numpy==1.24.0
26+
oldestdeps: matplotlib==3.7.0
27+
28+
# TODO: add pure python dependency, so we can add an example for the github install
29+
devdeps: git+https://github.com/astropy/pyvo.git#egg=pyvo
30+
31+
allowlist_externals = bash, sed
32+
33+
commands =
34+
pip freeze
35+
36+
## Some of the these could be factored out to a separate shell script,
37+
## but so far it's simple enought to keep it here.
38+
39+
40+
# Ignore testing the tutorials listed in ignore_testing file. We have some OS specific ignores,
41+
# too due to issues with e.g. multiprocessing and problems in upstream dependency
42+
!buildhtml: bash -c 'if python -c "import platform; print(platform.platform())" | grep -i macos; then cat ignore_osx_testing >> ignore_testing; fi'
43+
!buildhtml: bash -c 'if python -c "import platform; print(platform.platform())" | grep -i win; then cat ignore_windows_testing >> ignore_testing; fi'
44+
45+
!buildhtml: bash -c 'if [[ $CI == true ]]; then cat ignore_gha_testing >> ignore_testing; fi'
46+
47+
# We only want to run CI in PRs for the notebooks we touched
48+
!buildhtml: bash -c 'if [[ $GITHUB_EVENT_NAME == pull_request && -z "$(grep force_run:all_tests ${GITHUB_EVENT_PATH})" ]]; then git fetch origin main --depth=1; git diff origin/main --name-only tutorials | grep .md; else find tutorials -name "*.md"; fi | grep -vf ignore_testing | xargs jupytext --to notebook '
49+
50+
!buildhtml: pytest --nbval-lax -vv --suppress-no-test-exit-code --durations=10 tutorials
51+
52+
buildhtml: sphinx-build -b html . _build/html -nWT --keep-going
53+
# SED magic to remove the toctree captions from the rendered index page while keeping them in the sidebar TOC
54+
buildhtml: sed -E -i.bak '/caption-text/{N; s/.+caption-text.+\n<ul>/<ul>/; P;D;}' _build/html/index.html
55+
buildhtml: bash -c 'rm _build/html/index.html.bak'
56+
57+
pip_pre =
58+
predeps: true
59+
!predeps: false
60+
61+
skip_install = true

0 commit comments

Comments
 (0)