Skip to content

Commit 5752267

Browse files
committed
Adopt tox
1 parent bc17f43 commit 5752267

File tree

17 files changed

+160
-429
lines changed

17 files changed

+160
-429
lines changed

.github/workflows/benchmark.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
IRIS_TEST_DATA_PATH: benchmarks/iris-test-data
2929
IRIS_TEST_DATA_VERSION: "2.19"
3030
# Lets us manually bump the cache to rebuild
31-
ENV_CACHE_BUILD: "0"
31+
ENV_CACHE_BUILD: "1"
3232
TEST_DATA_CACHE_BUILD: "2"
3333

3434
steps:
@@ -37,16 +37,16 @@ jobs:
3737
with:
3838
fetch-depth: 0
3939

40-
- name: Install ASV & Nox
40+
- name: Install ASV & tox
4141
run: |
42-
pip install asv nox
42+
pip install asv tox
4343
4444
- name: Cache environment directories
4545
id: cache-env-dir
4646
uses: actions/cache@v3
4747
with:
4848
path: |
49-
.nox
49+
.tox
5050
benchmarks/.asv/env
5151
$CONDA/pkgs
5252
key: ${{ runner.os }}-${{ hashFiles('requirements/') }}-${{ env.ENV_CACHE_BUILD }}

.github/workflows/ci-tests.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
os: ["ubuntu-latest"]
38-
python-version: ["3.11"]
39-
session: ["doctest", "gallery", "linkcheck"]
38+
python-version: ["311"]
39+
session: ["docs-tests", "docs-linkcheck", "gallery_tests"]
4040
include:
4141
- os: "ubuntu-latest"
42-
python-version: "3.11"
42+
python-version: "311"
4343
session: "tests"
44-
coverage: "--coverage"
44+
posargs: "--cov=lib/iris --cov-report=xml"
4545
- os: "ubuntu-latest"
46-
python-version: "3.10"
46+
python-version: "310"
4747
session: "tests"
4848
- os: "ubuntu-latest"
49-
python-version: "3.9"
49+
python-version: "39"
5050
session: "tests"
5151

5252
env:
@@ -63,7 +63,7 @@ jobs:
6363
CACHE_WEEKS: 2
6464
run: |
6565
echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV}
66-
echo "LOCK_FILE=requirements/locks/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV}
66+
echo "LOCK_FILE=requirements/locks/py$(echo ${{ matrix.python-version }})-linux-64.lock" >> ${GITHUB_ENV}
6767
6868
- name: "data cache"
6969
uses: ./.github/workflows/composite/iris-data-cache
@@ -91,10 +91,10 @@ jobs:
9191
- name: "conda environment cache"
9292
uses: ./.github/workflows/composite/conda-env-cache
9393
with:
94-
cache_build: 0
94+
cache_build: 1
9595
cache_period: ${{ env.CACHE_PERIOD }}
9696
env_name: ${{ env.ENV_NAME }}
97-
install_packages: "cartopy nox pip"
97+
install_packages: "cartopy tox'<4'"
9898

9999
- name: "conda info"
100100
run: |
@@ -108,8 +108,8 @@ jobs:
108108
cache_period: ${{ env.CACHE_PERIOD }}
109109
env_name: ${{ env.ENV_NAME }}
110110

111-
- name: "nox cache"
112-
uses: ./.github/workflows/composite/nox-cache
111+
- name: "tox cache"
112+
uses: ./.github/workflows/composite/tox-cache
113113
with:
114114
cache_build: 2
115115
env_name: ${{ env.ENV_NAME }}
@@ -134,11 +134,9 @@ jobs:
134134
cat ${MPL_RC}
135135
136136
- name: "iris ${{ matrix.session }}"
137-
env:
138-
PY_VER: ${{ matrix.python-version }}
139137
run: |
140-
nox --session ${{ matrix.session }} -- --verbose ${{ matrix.coverage }}
138+
tox -e py${{ matrix.python-version }}-${{ matrix.session }} -- ${{ matrix.posargs }}
141139
142140
- name: Upload coverage report
143141
uses: codecov/codecov-action@v3
144-
if: ${{ matrix.coverage }}
142+
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
@@ -52,7 +52,7 @@ jobs:
5252
strategy:
5353
fail-fast: false
5454
matrix:
55-
python-version: ["3.9", "3.10", "3.11"]
55+
python-version: ["39", "310", "311"]
5656
session: ["wheel"]
5757
env:
5858
ENV_NAME: "ci-wheels"
@@ -72,7 +72,7 @@ jobs:
7272
CACHE_WEEKS: 2
7373
run: |
7474
echo "CACHE_PERIOD=$(date +%Y).$(expr $(date +%U) / ${CACHE_WEEKS})" >> ${GITHUB_ENV}
75-
echo "LOCK_FILE=requirements/locks/py$(echo ${{ matrix.python-version }} | tr -d '.')-linux-64.lock" >> ${GITHUB_ENV}
75+
echo "LOCK_FILE=requirements/locks/py$(echo ${{ matrix.python-version }})-linux-64.lock" >> ${GITHUB_ENV}
7676
7777
- name: "conda package cache"
7878
uses: ./.github/workflows/composite/conda-pkg-cache
@@ -93,23 +93,21 @@ jobs:
9393
- name: "conda environment cache"
9494
uses: ./.github/workflows/composite/conda-env-cache
9595
with:
96-
cache_build: 0
96+
cache_build: 1
9797
cache_period: ${{ env.CACHE_PERIOD }}
9898
env_name: ${{ env.ENV_NAME }}
99-
install_packages: "nox pip"
99+
install_packages: "tox'<4' pip"
100100

101-
- name: "nox cache"
102-
uses: ./.github/workflows/composite/nox-cache
101+
- name: "tox cache"
102+
uses: ./.github/workflows/composite/tox-cache
103103
with:
104104
cache_build: 1
105105
env_name: ${{ env.ENV_NAME }}
106106
lock_file: ${{ env.LOCK_FILE }}
107107

108-
- name: "nox install and test wheel"
109-
env:
110-
PY_VER: ${{ matrix.python-version }}
108+
- name: "tox install and test wheel"
111109
run: |
112-
nox --session ${{ matrix.session }} -- --verbose
110+
tox -e py${{ matrix.python-version }}-${{ matrix.session }}
113111
114112
show-artifacts:
115113
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) }}

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
files: |
55
(?x)(
6-
noxfile\.py|
76
setup\.py|
87
docs\/.+\.py|
98
lib\/.+\.py|

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ exclude codecov.yml
2020
include COPYING
2121
include COPYING.LESSER
2222
exclude Makefile
23-
exclude noxfile.py
23+
exclude tox.ini
2424

2525
# files required to build iris.std_names module
2626
include etc/cf-standard-name-table.xml

benchmarks/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ by the PR. (This run is managed by
2121
[the aforementioned GitHub Action](../.github/workflows/benchmark.yml)).
2222

2323
`asv ...` commands must be run from this directory. You will need to have ASV
24-
installed, as well as Nox (see
24+
installed, as well as tox (see
2525
[Benchmark environments](#benchmark-environments)).
2626

2727
The benchmark runner ([bm_runner.py](./bm_runner.py)) provides conveniences for
@@ -107,13 +107,12 @@ suites for the UK Met Office NG-VAT project.
107107
## Benchmark environments
108108

109109
We have disabled ASV's standard environment management, instead using an
110-
environment built using the same Nox scripts as Iris' test environments. This
111-
is done using ASV's plugin architecture - see
110+
environment built using tox. This is done using ASV's plugin architecture - see
112111
[asv_delegated_conda.py](asv_delegated_conda.py) and the extra config items in
113112
[asv.conf.json](asv.conf.json).
114113

115114
(ASV is written to control the environment(s) that benchmarks are run in -
116115
minimising external factors and also allowing it to compare between a matrix
117116
of dependencies (each in a separate environment). We have chosen to sacrifice
118117
these features in favour of testing each commit with its intended dependencies,
119-
controlled by Nox + lock-files).
118+
controlled by tox + lock-files).

benchmarks/bm_runner.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,29 @@ def _prep_data_gen_env() -> None:
6262
"""
6363

6464
root_dir = BENCHMARKS_DIR.parent
65-
python_version = "3.11"
65+
python_version = "311"
6666
data_gen_var = "DATA_GEN_PYTHON"
6767
if data_gen_var in environ:
6868
print("Using existing data generation environment.")
6969
else:
7070
print("Setting up the data generation environment ...")
71-
# Get Nox to build an environment for the `tests` session, but don't
72-
# run the session. Will re-use a cached environment if appropriate.
71+
# Get tox to build an environment. It will re-use a cached environment
72+
# if appropriate.
7373
_subprocess_run_print(
7474
[
75-
"nox",
76-
f"--noxfile={root_dir / 'noxfile.py'}",
77-
"--session=tests",
78-
"--install-only",
79-
f"--python={python_version}",
75+
"tox",
76+
"-c",
77+
root_dir,
78+
"-e",
79+
f"py{python_version}",
8080
]
8181
)
8282
# Find the environment built above, set it to be the data generation
8383
# environment.
8484
data_gen_python = next(
85-
(root_dir / ".nox").rglob(f"tests*/bin/python{python_version}")
85+
(root_dir / ".tox").rglob(
86+
f"py{python_version}/bin/python{python_version[:1]}.{python_version[1:]}"
87+
)
8688
).resolve()
8789
environ[data_gen_var] = str(data_gen_python)
8890

@@ -112,7 +114,7 @@ def _prep_data_gen_env() -> None:
112114

113115
def _setup_common() -> None:
114116
_check_requirements("asv")
115-
_check_requirements("nox")
117+
_check_requirements("tox")
116118

117119
_prep_data_gen_env()
118120

@@ -154,7 +156,7 @@ def _asv_compare(*commits: str, overnight_mode: bool = False) -> None:
154156

155157

156158
class _SubParserGenerator(ABC):
157-
"""Convenience for holding all the necessary argparse info in 1 place."""
159+
"""Convenience for holding all the necessary argparse info in one place."""
158160

159161
name: str = NotImplemented
160162
description: str = NotImplemented

docs/src/common_links.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
.. _sphinx: https://www.sphinx-doc.org/en/master/
3838
.. _sphinx-apidoc: https://github.com/sphinx-contrib/apidoc
3939
.. _test-iris-imagehash: https://github.com/SciTools/test-iris-imagehash
40+
.. _tox: https://tox.readthedocs.io/en/latest/
4041
.. _using git: https://docs.github.com/en/github/using-git
4142
.. _requirements: https://github.com/SciTools/iris/tree/main/requirements
4243
.. _CF-UGRID: https://ugrid-conventions.github.io/ugrid-conventions/

docs/src/developers_guide/contributing_pull_request_checklist.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ is merged. Before submitting a pull request please consider the following:
3030
:ref:`code_formatting`.
3131

3232
#. **Check all new dependencies added to the** `requirements`_ **yaml
33-
files.** If dependencies have been added then new nox testing lockfiles
33+
files.** If dependencies have been added then new testing lockfiles
3434
should be generated too, see :ref:`gha_test_env`.
3535

3636
#. **Check the source documentation been updated to explain all new or changed

0 commit comments

Comments
 (0)