Skip to content

Commit 9b39783

Browse files
committed
Adopt tox
1 parent 2056703 commit 9b39783

File tree

7 files changed

+121
-88
lines changed

7 files changed

+121
-88
lines changed

.github/workflows/ci-tests.yml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,28 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
os: ["ubuntu-latest"]
38-
python-version: ["3.10"]
39-
session: ["doctest", "gallery", "linkcheck"]
38+
python-version: ["310"]
39+
session: ["docs-tests", "docs-linkcheck"]
4040
include:
4141
- os: "ubuntu-latest"
42-
python-version: "3.10"
42+
python-version: "310"
4343
session: "tests"
44-
coverage: "--coverage"
44+
posargs: "--gallery-tests"
4545
- os: "ubuntu-latest"
46-
python-version: "3.9"
46+
python-version: "310"
4747
session: "tests"
48+
posargs: "--cov=lib/iris --cov-report=xml"
4849
- os: "ubuntu-latest"
49-
python-version: "3.8"
50+
python-version: "39"
5051
session: "tests"
52+
- os: "ubuntu-latest"
53+
python-version: "38"
54+
session: "tests"
55+
- os: "ubuntu-latest"
56+
python-version: "310"
57+
session: "tests"
58+
posargs: "--gallery-tests"
59+
5160

5261
env:
5362
IRIS_TEST_DATA_VERSION: "2.19"
@@ -63,7 +72,7 @@ jobs:
6372
CACHE_WEEKS: 2
6473
run: |
6574
echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV}
66-
echo "LOCK_FILE=requirements/ci/nox.lock/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV}
75+
echo "LOCK_FILE=requirements/ci/locks/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV}
6776
6877
- name: "data cache"
6978
uses: ./.github/workflows/composite/iris-data-cache
@@ -91,10 +100,10 @@ jobs:
91100
- name: "conda environment cache"
92101
uses: ./.github/workflows/composite/conda-env-cache
93102
with:
94-
cache_build: 0
103+
cache_build: 1
95104
cache_period: ${{ env.CACHE_PERIOD }}
96105
env_name: ${{ env.ENV_NAME }}
97-
install_packages: "cartopy nox pip"
106+
install_packages: "cartopy tox'<4'"
98107

99108
- name: "conda info"
100109
run: |
@@ -108,8 +117,8 @@ jobs:
108117
cache_period: ${{ env.CACHE_PERIOD }}
109118
env_name: ${{ env.ENV_NAME }}
110119

111-
- name: "nox cache"
112-
uses: ./.github/workflows/composite/nox-cache
120+
- name: "tox cache"
121+
uses: ./.github/workflows/composite/tox-cache
113122
with:
114123
cache_build: 0
115124
env_name: ${{ env.ENV_NAME }}
@@ -134,11 +143,9 @@ jobs:
134143
cat ${MPL_RC}
135144
136145
- name: "iris ${{ matrix.session }}"
137-
env:
138-
PY_VER: ${{ matrix.python-version }}
139146
run: |
140-
nox --session ${{ matrix.session }} -- --verbose ${{ matrix.coverage }}
147+
tox -e py${{ matrix.python-version }}-${{ matrix.session }} -- ${{ matrix.posargs }}
141148
142149
- name: Upload coverage report
143150
uses: codecov/codecov-action@v3
144-
if: ${{ matrix.coverage }}
151+
if: contains(${{ matrix.posargs }}, "--cov=lib/iris --cov-report=xml")

.github/workflows/ci-wheels.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
strategy:
5555
fail-fast: false
5656
matrix:
57-
python-version: ["3.8", "3.9", "3.10"]
57+
python-version: ["38", "39", "310"]
5858
session: ["wheel"]
5959
env:
6060
ENV_NAME: "ci-wheels"
@@ -74,7 +74,7 @@ jobs:
7474
CACHE_WEEKS: 2
7575
run: |
7676
echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV}
77-
echo "LOCK_FILE=requirements/ci/nox.lock/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV}
77+
echo "LOCK_FILE=requirements/ci/locks/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV}
7878
7979
- name: "conda package cache"
8080
uses: ./.github/workflows/composite/conda-pkg-cache
@@ -95,23 +95,21 @@ jobs:
9595
- name: "conda environment cache"
9696
uses: ./.github/workflows/composite/conda-env-cache
9797
with:
98-
cache_build: 0
98+
cache_build: 1
9999
cache_period: ${{ env.CACHE_PERIOD }}
100100
env_name: ${{ env.ENV_NAME }}
101-
install_packages: "nox pip"
101+
install_packages: "tox'<4' pip"
102102

103-
- name: "nox cache"
104-
uses: ./.github/workflows/composite/nox-cache
103+
- name: "tox cache"
104+
uses: ./.github/workflows/composite/tox-cache
105105
with:
106106
cache_build: 0
107107
env_name: ${{ env.ENV_NAME }}
108108
lock_file: ${{ env.LOCK_FILE }}
109109

110-
- name: "nox install and test wheel"
111-
env:
112-
PY_VER: ${{ matrix.python-version }}
110+
- name: "tox install and test wheel"
113111
run: |
114-
nox --session ${{ matrix.session }} -- --verbose
112+
tox -e py${{ matrix.python-version }}-${{ matrix.session }}
115113
116114
show-artifacts:
117115
needs: build

.github/workflows/composite/nox-cache/action.yml renamed to .github/workflows/composite/tox-cache/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: "nox cache"
2-
description: "cache the nox test environments"
1+
name: "tox cache"
2+
description: "cache the tox test environments"
33

44
inputs:
55
cache_build:
6-
description: "nox cache build number"
6+
description: "tox cache build number"
77
required: false
88
default: "0"
99
env_name:
@@ -18,5 +18,5 @@ runs:
1818
steps:
1919
- uses: actions/cache@v3
2020
with:
21-
path: ${{ github.workspace }}/.nox
22-
key: ${{ runner.os }}-nox-${{ inputs.env_name }}-s${{ matrix.session }}-py${{ matrix.python-version }}-b${{ inputs.cache_build }}-${{ hashFiles(inputs.lock_file) }}
21+
path: ${{ github.workspace }}/.tox
22+
key: ${{ runner.os }}-tox-${{ inputs.env_name }}-s${{ matrix.session }}-py${{ matrix.python-version }}-b${{ inputs.cache_build }}-${{ hashFiles(inputs.lock_file) }}

docs/src/common_links.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
.. _scitools-iris: https://pypi.org/project/scitools-iris/
3636
.. _sphinx: https://www.sphinx-doc.org/en/master/
3737
.. _test-iris-imagehash: https://github.com/SciTools/test-iris-imagehash
38+
.. _tox: https://tox.readthedocs.io/en/latest/
3839
.. _using git: https://docs.github.com/en/github/using-git
3940
.. _requirements: https://github.com/SciTools/iris/tree/main/requirements
4041
.. _CF-UGRID: https://ugrid-conventions.github.io/ugrid-conventions/

docs/src/developers_guide/contributing_running_tests.rst

Lines changed: 45 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ There are two options for running the tests:
1212
the tests or use ``python`` interactively to investigate any issues. See
1313
:ref:`test manual env`.
1414

15-
* Use ``nox``. This will automatically generate an environment and run test
16-
sessions consistent with our GitHub continuous integration. See :ref:`using nox`.
15+
* Use ``tox``. This will automatically generate an environment and run test
16+
sessions consistent with our GitHub continuous integration. See :ref:`using tox`.
1717

1818
.. _test manual env:
1919

@@ -101,97 +101,84 @@ using the commands ``python test_mapping.py -h`` or
101101
``python test_mapping.py --help``.
102102

103103
.. tip:: A useful command line option to use is ``-d``. This will display
104-
matplotlib_ figures as the tests are run. For example::
104+
`matplotlib_` figures as the tests are run. For example::
105105

106106
python test_mapping.py -d
107107

108-
.. _using nox:
108+
.. _using tox:
109109

110-
Using Nox for Testing Iris
110+
Using tox for Testing Iris
111111
==========================
112112

113-
The `nox`_ tool has for adopted for automated testing on `Iris GitHub Actions`_
113+
The `tox`_ tool has been adopted for automated testing on `Iris GitHub Actions`_
114114
and also locally on the command-line for developers.
115115

116-
`nox`_ is similar to `tox`_, but instead leverages the expressiveness and power of a Python
117-
configuration file rather than an `.ini` style file. As with `tox`_, `nox`_ can use `virtualenv`_
118-
to create isolated Python environments, but in addition also supports `conda`_ as a testing
119-
environment backend.
116+
`tox`_ uses `virtualenv`_ to create isolated Python environments and is
117+
configured within a tox.ini file.
120118

121-
122-
Where is Nox Used?
119+
Where is tox Used?
123120
------------------
124121

125-
Iris uses `nox`_ as a convenience to fully automate the process of executing the Iris tests, but also
126-
automates the process of:
122+
Iris uses `tox`_ as a convenience to fully automate the process of:
127123

128-
* building the documentation and executing the doc-tests
129-
* building the documentation gallery
124+
* executing the Iris tests,
125+
* building the documentation,
126+
* executing the doc-tests,
127+
* executing the gallery tests, and
130128
* running the documentation URL link check
131129

132-
You can perform all of these tasks manually yourself, however the onus is on you to first ensure
133-
that all of the required package dependencies are installed and available in the testing environment.
130+
You can perform all of these tasks manually yourself, however the onus is on you
131+
to first ensure that all of the required package dependencies are installed and
132+
available in the testing environment.
134133

135-
`Nox`_ has been configured to automatically do this for you, and provides a means to easily replicate
136-
the remote testing behaviour of `Iris GitHub Actions`_ locally for the developer.
134+
`tox`_ has been configured to automatically do this for you, and provides a
135+
means to easily replicate the remote testing behaviour of `Iris GitHub Actions`_
136+
locally for the developer.
137137

138138

139-
Installing Nox
139+
Installing tox
140140
--------------
141141

142-
We recommend installing `nox`_ using `conda`_. To install `nox`_ in a separate `conda`_ environment::
142+
We recommend installing `tox`_ using `conda`_. To install `tox`_ in a separate
143+
`conda`_ environment::
143144

144-
conda create -n nox -c conda-forge nox
145-
conda activate nox
145+
conda create -n tox -c conda-forge tox
146+
conda activate tox
146147

147-
To install `nox`_ in an existing active `conda`_ environment::
148+
To install `tox`_ in an existing active `conda`_ environment::
148149

149-
conda install -c conda-forge nox
150+
conda install -c conda-forge tox
150151

151-
The `nox`_ package is also available on PyPI, however `nox`_ has been configured to use the `conda`_
152-
backend for Iris, so an installation of `conda`_ must always be available.
152+
The `tox`_ package is also available on PyPI, however `tox`_ has been configured
153+
to use `conda`_ to create the testing environments and so an installation of
154+
`conda`_ must always be available.
153155

154156

155-
Testing with Nox
157+
Testing with tox
156158
----------------
157159

158-
The `nox`_ configuration file `noxfile.py` is available in the root ``iris`` project directory, and
159-
defines all the `nox`_ sessions (i.e., tasks) that may be performed. `nox`_ must always be executed
160-
from the ``iris`` root directory.
161-
162-
To list the configured `nox`_ sessions for Iris::
163-
164-
nox --list
165-
166-
To run the Iris tests for all configured versions of Python::
160+
The `tox`_ configuration file `tox.ini` is available in the root ``iris``
161+
project directory, and defines all the `tox`_ test environments (i.e., tasks)
162+
that may be performed. `tox`_ must always be executed from the ``iris`` root
163+
directory.
167164

168-
nox --session tests
165+
To list the configured `tox`_ sessions for Iris::
169166

170-
To build the Iris documentation specifically for Python 3.7::
167+
tox --listenvs-all
171168

172-
nox --session doctest-3.7
169+
To run the Iris tests for Python 3.10::
173170

174-
To run all the Iris `nox`_ sessions::
171+
tox -e py310-tests
175172

176-
nox
173+
To build the Iris documentation specifically for Python 3.10::
177174

178-
For further `nox`_ command-line options::
179-
180-
nox --help
181-
182-
.. tip::
183-
For `nox`_ sessions that use the `conda`_ backend, you can use the ``-v`` or ``--verbose``
184-
flag to display the `nox`_ `conda`_ environment package details and environment info.
185-
For example::
175+
tox -e py310-docs
186176

187-
nox --session tests -- --verbose
177+
For further `tox`_ command-line options::
188178

179+
tox --help
189180

190-
.. note:: `nox`_ will cache its testing environments in the `.nox` root ``iris`` project directory.
181+
.. note:: `tox`_ will cache its testing environments in the `.tox` root ``iris`` project directory.
191182

192183

193-
.. _setuptools: https://setuptools.readthedocs.io/en/latest/
194-
.. _tox: https://tox.readthedocs.io/en/latest/
195-
.. _virtualenv: https://virtualenv.pypa.io/en/latest/
196-
.. _PyPI: https://pypi.org/project/nox/
197-
.. _v41.5.0: https://setuptools.readthedocs.io/en/latest/history.html#v41-5-0
184+
.. _virtualenv: https://virtualenv.pypa.io/en/latest/

docs/src/whatsnew/latest.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ This document explains the changes made to Iris for this release
140140
#. `@lbdreyer`_ removed the Iris TestRunner. Tests are now run via nox or
141141
pytest. (:pull:`5205`)
142142

143+
# `@lbdreyer`_ replaced nox with tox as the automated test runnner.
144+
(:pull:`5184`)
145+
143146

144147
.. comment
145148
Whatsnew author names (@github name) in alphabetical order. Note that,

tox.ini

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[tox]
2+
requires =
3+
tox-conda
4+
5+
[testenv]
6+
conda_spec =
7+
py38: {toxinidir}{/}requirements{/}locks{/}py38-linux-64.lock
8+
py39: {toxinidir}{/}requirements{/}locks{/}py39-linux-64.lock
9+
py310: {toxinidir}{/}requirements{/}locks{/}py310-linux-64.lock
10+
11+
[testenv:py{38,39,310}-tests]
12+
description = Perform Iris unit, integration and system tests.
13+
usedevelop =
14+
true
15+
commands =
16+
pytest -n auto {posargs} {toxinidir}{/}lib{/}iris{/}tests
17+
18+
[testenv:py{38,39,310}-docs{,-linkcheck,-tests}]
19+
description = Build, and optionally linkcheck or test, the Iris documentation
20+
allowlist_externals =
21+
make
22+
changedir =
23+
{toxinidir}{/}docs
24+
usedevelop =
25+
true
26+
commands =
27+
make clean html
28+
linkcheck: make linkcheck
29+
tests: make doctest
30+
31+
[testenv:py{38,39,310}-wheel]
32+
description = Install wheel and test Iris import
33+
skip_install = true
34+
deps =
35+
{toxinidir}{/}dist{/}scitools_iris*.whl
36+
commands =
37+
python -c "import iris; print(f'\{iris.__version__=\}')"

0 commit comments

Comments
 (0)