Skip to content

Commit 62bcb99

Browse files
committed
Adopt tox
1 parent b8f5eea commit 62bcb99

File tree

10 files changed

+146
-416
lines changed

10 files changed

+146
-416
lines changed

.github/workflows/ci-tests.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,24 @@ 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+
5156

5257
env:
5358
IRIS_TEST_DATA_VERSION: "2.19"
@@ -63,7 +68,7 @@ jobs:
6368
CACHE_WEEKS: 2
6469
run: |
6570
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}
71+
echo "LOCK_FILE=requirements/ci/locks/py$(echo ${{ matrix.python-version }})-linux-64.lock" >> ${GITHUB_ENV}
6772
6873
- name: "data cache"
6974
uses: ./.github/workflows/composite/iris-data-cache
@@ -91,10 +96,10 @@ jobs:
9196
- name: "conda environment cache"
9297
uses: ./.github/workflows/composite/conda-env-cache
9398
with:
94-
cache_build: 0
99+
cache_build: 1
95100
cache_period: ${{ env.CACHE_PERIOD }}
96101
env_name: ${{ env.ENV_NAME }}
97-
install_packages: "cartopy nox pip"
102+
install_packages: "cartopy tox'<4'"
98103

99104
- name: "conda info"
100105
run: |
@@ -108,8 +113,8 @@ jobs:
108113
cache_period: ${{ env.CACHE_PERIOD }}
109114
env_name: ${{ env.ENV_NAME }}
110115

111-
- name: "nox cache"
112-
uses: ./.github/workflows/composite/nox-cache
116+
- name: "tox cache"
117+
uses: ./.github/workflows/composite/tox-cache
113118
with:
114119
cache_build: 1
115120
env_name: ${{ env.ENV_NAME }}
@@ -134,11 +139,9 @@ jobs:
134139
cat ${MPL_RC}
135140
136141
- name: "iris ${{ matrix.session }}"
137-
env:
138-
PY_VER: ${{ matrix.python-version }}
139142
run: |
140-
nox --session ${{ matrix.session }} -- --verbose ${{ matrix.coverage }}
143+
tox -e py${{ matrix.python-version }}-${{ matrix.session }} -- ${{ matrix.posargs }}
141144
142145
- name: Upload coverage report
143146
uses: codecov/codecov-action@v3
144-
if: ${{ matrix.coverage }}
147+
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 }})-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) }}

benchmarks/bm_runner.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,27 @@ def _prep_data_gen_env() -> None:
4848
"""
4949

5050
root_dir = Path(__file__).parents[1]
51-
python_version = "3.10"
51+
python_version = "310"
5252
data_gen_var = "DATA_GEN_PYTHON"
5353
if data_gen_var in environ:
5454
print("Using existing data generation environment.")
5555
else:
5656
print("Setting up the data generation environment ...")
57-
# Get Nox to build an environment for the `tests` session, but don't
58-
# run the session. Will re-use a cached environment if appropriate.
57+
# Get tox to build an environment. It will re-use a cached environment
58+
# if appropriate.
5959
subprocess.run(
6060
[
61-
"nox",
62-
f"--noxfile={root_dir / 'noxfile.py'}",
63-
"--session=tests",
64-
"--install-only",
65-
f"--python={python_version}",
61+
"tox",
62+
f"-c {root_dir / 'tox.ini'}",
63+
f"-e py{python_version}",
6664
]
6765
)
6866
# Find the environment built above, set it to be the data generation
6967
# environment.
7068
data_gen_python = next(
71-
(root_dir / ".nox").rglob(f"tests*/bin/python{python_version}")
69+
(root_dir / ".tox").rglob(
70+
f"py{python_version}/bin/python{python_version[:1]}.{python_version[1:]}"
71+
)
7272
).resolve()
7373
environ[data_gen_var] = str(data_gen_python)
7474

@@ -98,7 +98,7 @@ def _prep_data_gen_env() -> None:
9898

9999
def _setup_common() -> None:
100100
_check_requirements("asv")
101-
_check_requirements("nox")
101+
_check_requirements("tox")
102102

103103
_prep_data_gen_env()
104104

@@ -140,7 +140,7 @@ def _asv_compare(*commits: str, overnight_mode: bool = False) -> None:
140140

141141

142142
class _SubParserGenerator(ABC):
143-
"""Convenience for holding all the necessary argparse info in 1 place."""
143+
"""Convenience for holding all the necessary argparse info in one place."""
144144

145145
name: str = NotImplemented
146146
description: str = NotImplemented

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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ This document explains the changes made to Iris for this release
132132
(:pull:`5101`)
133133

134134
#. `@lbdreyer`_ and `@trexfeathers`_ (reviewer) added coverage testing. This
135-
can be enabled by using the "--coverage" flag when running the tests with
136-
nox i.e. ``nox --session tests -- --coverage``. (:pull:`4765`)
135+
can be enabled when running with tox i.e. ``tox -e py310-tests -- --cov``.
136+
(:pull:`4765`)
137137

138138
#. `@lbdreyer`_ and `@trexfeathers`_ (reviewer) removed the ``--coding-tests``
139139
option from Iris' test runner. (:pull:`4765`)
@@ -147,6 +147,9 @@ This document explains the changes made to Iris for this release
147147
#. `@trexfeathers`_ moved the benchmark runner conveniences from ``noxfile.py``
148148
to a dedicated ``benchmarks/bm_runner.py``. (:pull:`5215`)
149149

150+
# `@lbdreyer`_ replaced nox with tox as the automated test runner.
151+
(:pull:`5184`)
152+
150153

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

0 commit comments

Comments
 (0)