Skip to content

Commit

Permalink
upgrade to tox>=4.0, adjust tox configuration to set pytest-xdist and…
Browse files Browse the repository at this point in the history
… coverage options as needed, adjust pyproject.toml to not use pytest-xdist/report coverage by default
  • Loading branch information
Zeitsperre committed Feb 14, 2023
1 parent c7cfc8d commit b69b867
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
- submitted

env:
MAIN_TESTDATA_BRANCH: main
XCLIM_TESTDATA_BRANCH: main

jobs:
black:
Expand Down Expand Up @@ -115,8 +115,9 @@ jobs:
python -m pip install --no-user .
- name: Test
run: |
pip list
pip check
pytest xclim --durations=10
pytest xclim --num-workers=logical --durations=10 --cov=xclim --cov-report=term-missing
env:
CONDA_EXE: mamba
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -184,10 +185,6 @@ jobs:
run: pylint --rcfile=pylintrc --disable=import-error --exit-zero xclim
- name: Test with tox
run: tox -e notebooks_doctests
- name: Report coverage
run: |
pip install --upgrade coveralls
coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-notebooks_doctests-py38
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,8 @@ ignore_missing_imports = true
addopts = [
"--verbose",
"--color=yes",
"--cov=xclim",
"--cov-report=term-missing",
"--numprocesses=auto",
"--maxprocesses=6",
"--numprocesses=0",
"--maxprocesses=8",
"--dist=worksteal"
]
norecursedirs = ["docs/notebooks/*"]
Expand Down
27 changes: 16 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
[tox]
min_version = 4.0
env_list =
black
docs
notebooks_doctests
notebooks_doctests{-coverage,}
; opt-slow
py38-lm3
py39-upstream-doctest
py310-slow
isolated_build = True
requires =
pip >= 21.0
tox ~=3.0
opts = -v

[testenv:black]
Expand All @@ -35,6 +34,7 @@ commands =
blackdoc --check docs
isort --check xclim
yamllint --config-file=.yamllint.yaml xclim
commands_post =

[testenv:docs]
description = Build the documentation with makefile under {basepython}
Expand All @@ -44,6 +44,7 @@ setenv =
READTHEDOCS = 1
commands =
make docs
commands_post =
allowlist_externals =
env
make
Expand All @@ -55,11 +56,11 @@ allowlist_externals =
;conda_env = environment-dev.yml
;extras =

[testenv:notebooks_doctests]
[testenv:notebooks_doctests{-coverage,}]
description = Run notebooks and doctests with pytest under {basepython}
commands =
pytest --no-cov --nbval --dist=loadscope docs/notebooks --durations=10 --ignore=docs/notebooks/example.ipynb
pytest --rootdir xclim/testing/tests/ --xdoctest xclim --ignore=xclim/testing/tests/ --durations=10
pytest --no-cov --nbval --dist=loadscope docs/notebooks --ignore=docs/notebooks/example.ipynb
pytest --rootdir xclim/testing/tests/ --xdoctest xclim --ignore=xclim/testing/tests/

# Requires tox-conda compatible with tox@v4.0
;[testenv:opt-{slow,not_slow}]
Expand All @@ -76,27 +77,31 @@ commands =
description = Run tests with pytest under {basepython}
setenv =
COV_CORE_SOURCE =
PYTEST_ADDOPTS = --numprocesses=logical --durations=10
coverage: PYTEST_ADDOPTS = --numprocesses=logical --durations=10 --cov=xclim --cov-report=term-missing
PYTHONPATH = {toxinidir}
passenv =
CI
CONDA_EXE
COVERALLS_*
GITHUB_*
LD_LIBRARY_PATH
MAIN_TESTDATA_BRANCH
XCLIM_*
extras = dev
deps =
coverage: coveralls
lm3: git+https://github.com/OpenHydrology/lmoments3.git@develop#egg=lmoments3
upstream: -rrequirements_upstream.txt
install_command = python -m pip install --no-user {opts} {packages}
download = True
commands =
commands_pre =
pip list
pip check
doctest: pytest --no-cov --rootdir xclim/testing/tests/ --xdoctest xclim --ignore=xclim/testing/tests/ --durations=10
!slow: pytest xclim -m "not slow" --durations=10
slow: pytest xclim --durations=10
commands =
doctest: pytest --no-cov --rootdir xclim/testing/tests/ --xdoctest xclim --ignore=xclim/testing/tests/
!slow: pytest xclim -m "not slow"
slow: pytest xclim
commands_post =
coverage: - coveralls
allowlist_externals =
git

0 comments on commit b69b867

Please sign in to comment.