Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nox session conda list #3990

Merged
merged 4 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ linux_minimal_task:
tests_script:
- echo "[Resources]" > ${SITE_CFG}
- echo "doc_dir = ${CIRRUS_WORKING_DIR}/docs" >> ${SITE_CFG}
- nox --session tests
- nox --session tests -- --verbose


#
Expand Down Expand Up @@ -137,7 +137,7 @@ linux_task:
- echo "[Resources]" > ${SITE_CFG}
- echo "test_data_dir = ${IRIS_TEST_DATA_DIR}/test_data" >> ${SITE_CFG}
- echo "doc_dir = ${CIRRUS_WORKING_DIR}/docs" >> ${SITE_CFG}
- nox --session tests
- nox --session tests -- --verbose


#
Expand Down Expand Up @@ -167,7 +167,7 @@ gallery_task:
- echo "[Resources]" > ${SITE_CFG}
- echo "test_data_dir = ${IRIS_TEST_DATA_DIR}/test_data" >> ${SITE_CFG}
- echo "doc_dir = ${CIRRUS_WORKING_DIR}/docs" >> ${SITE_CFG}
- nox --session gallery
- nox --session gallery -- --verbose


#
Expand Down Expand Up @@ -201,7 +201,7 @@ doctest_task:
- mkdir -p ${MPL_RC_DIR}
- echo "backend : agg" > ${MPL_RC_FILE}
- echo "image.cmap : viridis" >> ${MPL_RC_FILE}
- nox --session doctest
- nox --session doctest -- --verbose


#
Expand All @@ -224,4 +224,4 @@ link_task:
- mkdir -p ${MPL_RC_DIR}
- echo "backend : agg" > ${MPL_RC_FILE}
- echo "image.cmap : viridis" >> ${MPL_RC_FILE}
- nox --session linkcheck
- nox --session linkcheck -- --verbose
8 changes: 8 additions & 0 deletions docs/src/developers_guide/contributing_running_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ For further `nox`_ command-line options::

nox --help

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

.. tip::
For `nox`_ sessions that use the `conda`_ backend, you can use the ``-v`` or ``--verbose``
flag to display the `nox`_ `conda`_ environment package details and environment info.
For example::

nox --session tests -- --verbose


.. note:: `nox`_ will cache its testing environments in the `.nox` root ``iris`` project directory.


Expand Down
4 changes: 4 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ This document explains the changes made to Iris for this release

#. `@jamesp`_ updated a test to the latest numpy version (:pull:`3977`)

#. `@bjlittle`_ rationalised the ``noxfile.py``, and added the ability for
each ``nox`` session to list its ``conda`` environment packages and
environment info. (:pull:`3990`)


.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
Expand Down
148 changes: 56 additions & 92 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,58 @@ def cache_cartopy(session):
)


def prepare_venv(session):
"""
Create and cache the nox session conda environment, and additionally
provide conda environment package details and info.

Note that, iris is installed into the environment using pip.

Parameters
----------
session: object
A `nox.sessions.Session` object.

Notes
-----
See
- https://github.com/theacodes/nox/issues/346
- https://github.com/theacodes/nox/issues/260

"""
if not venv_cached(session):
# Determine the conda requirements yaml file.
fname = f"requirements/ci/py{session.python.replace('.', '')}.yml"
# Back-door approach to force nox to use "conda env update".
command = (
"conda",
"env",
"update",
f"--prefix={session.virtualenv.location}",
f"--file={fname}",
"--prune",
)
session._run(*command, silent=True, external="error")
cache_venv(session)

cache_cartopy(session)
session.install("--no-deps", "--editable", ".")

# Determine whether verbose diagnostics have been requested
# from the command line.
verbose = "-v" in session.posargs or "--verbose" in session.posargs

if verbose:
session.run("conda", "info")
session.run("conda", "list", f"--prefix={session.virtualenv.location}")
session.run(
"conda",
"list",
f"--prefix={session.virtualenv.location}",
"--explicit",
)


@nox.session
def flake8(session):
"""
Expand Down Expand Up @@ -141,30 +193,8 @@ def tests(session):
session: object
A `nox.sessions.Session` object.

Notes
-----
See
- https://github.com/theacodes/nox/issues/346
- https://github.com/theacodes/nox/issues/260

"""
if not venv_cached(session):
# Determine the conda requirements yaml file.
fname = f"requirements/ci/py{session.python.replace('.', '')}.yml"
# Back-door approach to force nox to use "conda env update".
command = (
"conda",
"env",
"update",
f"--prefix={session.virtualenv.location}",
f"--file={fname}",
"--prune",
)
session._run(*command, silent=True, external="error")
cache_venv(session)

cache_cartopy(session)
session.install("--no-deps", "--editable", ".")
prepare_venv(session)
session.run(
"python",
"-m",
Expand All @@ -184,30 +214,8 @@ def gallery(session):
session: object
A `nox.sessions.Session` object.

Notes
-----
See
- https://github.com/theacodes/nox/issues/346
- https://github.com/theacodes/nox/issues/260

"""
if not venv_cached(session):
# Determine the conda requirements yaml file.
fname = f"requirements/ci/py{session.python.replace('.', '')}.yml"
# Back-door approach to force nox to use "conda env update".
command = (
"conda",
"env",
"update",
f"--prefix={session.virtualenv.location}",
f"--file={fname}",
"--prune",
)
session._run(*command, silent=True, external="error")
cache_venv(session)

cache_cartopy(session)
session.install("--no-deps", "--editable", ".")
prepare_venv(session)
session.run(
"python",
"-m",
Expand All @@ -226,30 +234,8 @@ def doctest(session):
session: object
A `nox.sessions.Session` object.

Notes
-----
See
- https://github.com/theacodes/nox/issues/346
- https://github.com/theacodes/nox/issues/260

"""
if not venv_cached(session):
# Determine the conda requirements yaml file.
fname = f"requirements/ci/py{session.python.replace('.', '')}.yml"
# Back-door approach to force nox to use "conda env update".
command = (
"conda",
"env",
"update",
f"--prefix={session.virtualenv.location}",
f"--file={fname}",
"--prune",
)
session._run(*command, silent=True, external="error")
cache_venv(session)

cache_cartopy(session)
session.install("--no-deps", "--editable", ".")
prepare_venv(session)
session.cd("docs")
session.run(
"make",
Expand All @@ -274,30 +260,8 @@ def linkcheck(session):
session: object
A `nox.sessions.Session` object.

Notes
-----
See
- https://github.com/theacodes/nox/issues/346
- https://github.com/theacodes/nox/issues/260

"""
if not venv_cached(session):
# Determine the conda requirements yaml file.
fname = f"requirements/ci/py{session.python.replace('.', '')}.yml"
# Back-door approach to force nox to use "conda env update".
command = (
"conda",
"env",
"update",
f"--prefix={session.virtualenv.location}",
f"--file={fname}",
"--prune",
)
session._run(*command, silent=True, external="error")
cache_venv(session)

cache_cartopy(session)
session.install("--no-deps", "--editable", ".")
prepare_venv(session)
session.cd("docs")
session.run(
"make",
Expand Down