Skip to content

Commit

Permalink
Reconfigure Builds and perform more doctests (#1709)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* Splits the `notebooks` recipe in the `tox.ini` file
* Sets the GitHub Workflows to test the doctests across more builds
* Stages the `tox-gh` plugin for eventual integration

### Does this PR introduce a breaking change?

Yes, `tox-gh` is now a development dependency and the
`"notebooks_doctests"` `tox` recipe has been replaced with
`"notebooks"`, while `doctest` has been made into a modifier for typical
`tox` runs to also run the documentation examples.

### Other information:

https://github.com/tox-dev/tox-gh
  • Loading branch information
Zeitsperre authored Apr 17, 2024
2 parents 0edfe42 + 982a656 commit d27b4ed
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 29 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:

concurrency:
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch except on main.
group: ${{ github.workflow }}-${{ github.ref }}
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

permissions:
Expand Down Expand Up @@ -57,8 +57,9 @@ jobs:
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
- name: Install pylint and tox
run: pip install pylint tox~=4.0
- name: Install pip, pylint, and tox
run: |
python -m pip install flit pip~=24.0 pylint tox~=4.0
- name: Run pylint
run: |
python -m pylint --rcfile=.pylintrc.toml --disable=import-error --exit-zero xclim
Expand Down Expand Up @@ -97,7 +98,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: |
python -m pip install tox~=4.0
python -m pip install flit pip~=24.0 tox~=4.0
- name: Test with tox
run: |
python -m tox -e ${{ matrix.tox-env }}
Expand All @@ -118,17 +119,17 @@ jobs:
matrix:
include:
# Windows builds
- tox-env: py39-prefetch-coverage
- tox-env: py39-coverage-prefetch
python-version: "3.9"
markers: -m 'not slow'
os: windows-latest
# macOS builds
- tox-env: py310-coverage
- tox-env: py310-coverage-lmoments-doctest
python-version: "3.10"
markers: -m 'not slow'
os: macos-latest
# Linux builds
- tox-env: py39-coverage-sbck
- tox-env: py39-coverage-sbck-doctest
python-version: "3.9"
markers: -m 'not slow'
os: ubuntu-latest
Expand All @@ -139,11 +140,11 @@ jobs:
python-version: "3.11"
markers: -m 'not slow'
os: ubuntu-latest
- tox-env: py312-coverage-numba
- tox-env: py312-coverage-lmoments-doctest
python-version: "3.12"
markers: -m 'not slow'
os: ubuntu-latest
- tox-env: notebooks_doctests
- tox-env: notebooks
python-version: "3.10"
os: ubuntu-latest
- tox-env: offline-prefetch
Expand Down Expand Up @@ -180,7 +181,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: |
python -m pip install tox~=4.0
python -m pip install flit pip~=24.0 tox~=4.0 tox-gh
- name: Test with tox
run: |
python -m tox -e ${{ matrix.tox-env }} -- ${{ matrix.markers }}
Expand All @@ -192,17 +193,16 @@ jobs:

test-conda:
needs: lint
name: test-conda-Python${{ matrix.python-version }}
name: Python${{ matrix.python-version }} (Conda, ${{ matrix.os }})
if: |
contains(github.event.pull_request.labels.*.name, 'approved') ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- python-version: "3.9"
- python-version: "3.12"
os: [ubuntu-latest]
python-version: ["3.9", "3.12"]
defaults:
run:
shell: bash -l {0}
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Bug fixes
Internal changes
^^^^^^^^^^^^^^^^
* Added "doymin" and "doymax" to the possible operations of ``generic.stats``. Fixed a warning issue when ``op`` was "integral". (:pull:`1672`).

* Reorganized GitHub CI build matrices to run the doctests more consistently. (:pull:`1709`).
* Removed the experimental `numba` and `llvm` dependency installation steps in the `tox.ini` file. Added `numba@main` to the upstream dependencies. (:pull:`1709`).
* Added the `tox-gh` dependency to the development installation recipe. This will soon be required for running the `tox` test ensemble on GitHub Workflows. (:pull:`1709`).

v0.48.2 (2024-02-26)
--------------------
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ dev = [
"tokenize-rt",
"tox >=4.0",
# "tox-conda", # Will be added when a tox@v4.0+ compatible plugin is released.
"tox-gh >=1.3.1",
"xdoctest",
"yamllint",
# Documentation and examples
Expand Down
1 change: 1 addition & 0 deletions requirements_upstream.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bottleneck @ git+https://github.com/pydata/bottleneck.git@master
cftime @ git+https://github.com/Unidata/cftime.git@master
flox @ git+https://github.com/xarray-contrib/flox.git@main
numba @ git+https://github.com/numba/numba.git@main
xarray @ git+https://github.com/pydata/xarray.git@main
32 changes: 19 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@ min_version = 4.0
env_list =
lint
docs
notebooks_doctests
notebooks
offline-prefetch
py39-upstream-doctest
py310
py310-doctest
py311-lmoments
py312-numba
py312-lmoments-doctest
labels =
test = py39, py310-upstream-doctest, py311, notebooks_doctests, offline-prefetch
requires =
pip >= 23.0
pip >= 24.0
flit
opts = -vv

[gh]
python =
3.12 = py312-coverage-lmoments-doctest
3.11 = py311-coverage-lmoments-sbck-doctest, offline-coverage-prefetch
3.10 = py310-coverage-lmoments-doctest, notebooks
3.9 = py39-coverage-sbck-doctest, lint, docs

[testenv:lint]
description = Run code quality compliance tests under {basepython}
skip_install = True
Expand Down Expand Up @@ -65,16 +73,15 @@ allowlist_externals =
;deps =
;extras =

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

[testenv:offline{-prefetch,}{-coverage,}]
description = Run tests with pytest under {basepython}, preventing socket connections (except for unix sockets for async support)
commands:
prefetch: xclim prefetch_testing_data
python -c 'print("Running offline tests with positional arguments: --disable-socket --allow-unix-socket --m \"not requires_internet\"")'
python -c 'print("These can be overwritten with: tox -e offline -- -m \"some other marker statement\"")'
pytest --disable-socket --allow-unix-socket {posargs:-m 'not requires_internet'}
Expand All @@ -99,14 +106,11 @@ passenv =
XCLIM_*
extras = dev
deps =
# FIXME: Remove when numba 0.59.0 is released
numba: numba==0.59.0rc1
numba: llvmlite==0.42.0rc1
coverage: coveralls
upstream: -rrequirements_upstream.txt
sbck: pybind11
lmoments: lmoments3
notebooks_doctests: lmoments3
notebooks: lmoments3
install_command = python -m pip install --no-user {opts} {packages}
download = True
commands_pre =
Expand All @@ -115,11 +119,13 @@ commands_pre =
xclim show_version_info
python -m pip check
xclim --help
prefetch: xclim prefetch_testing_data
commands =
prefetch: xclim prefetch_testing_data
doctest: pytest --no-cov --rootdir=tests/ --xdoctest xclim
pytest {posargs}
doctest: pytest --rootdir=tests/ --xdoctest xclim
commands_post =
coverage: - coveralls
allowlist_externals =
git
xclim

0 comments on commit d27b4ed

Please sign in to comment.