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

Improving noxfile speed #491

Merged
merged 1 commit into from
Oct 7, 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
12 changes: 12 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ then run the following command:

$ nox -s docs

This will re-use pre-existing environments if possible. To re-execute the installation commands, use this pattern:

.. code-block:: console

$ nox -s docs -- reinstall

Or to completely remove the environment generated by ``nox`` and start from scratch:

.. code-block:: console

$ rm -rf .nox/docs

If you've :ref:`manually set up your environment <manual-environment>`, you can build them with:

.. code-block:: console
Expand Down
17 changes: 12 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,42 @@
@nox.session(venv_backend="conda")
def build(session):
_install_environment(session)
session.run("yarn", "--frozen-lockfile")
session.run("yarn", "build")


@nox.session(venv_backend="conda")
def docs(session):
_install_environment(session)
session.run("yarn", "--frozen-lockfile")
session.cd("docs")
session.run("make", "html")


@nox.session(name="docs-live", venv_backend="conda")
def docs_live(session):
_install_environment(session)
session.run("yarn", "--frozen-lockfile")
session.run("yarn", "build:dev")


@nox.session(name="test", venv_backend="conda")
def tests(session):
_install_environment(session)
_install_environment(session, yarn=False)
session.run("pytest")


def _install_environment(session):
def _install_environment(session, yarn=True):
"""Install the JS and Python environment needed to develop the theme."""
# Assume that if sphinx is already installed, we don't need to re-install
bin = Path(session.bin)
if bin.rglob("sphinx-build") and "reinstall" not in session.posargs:
return

# Install JS and Python dependencies
session.conda_install("--channel", "conda-forge", *conda)
for pkg in requirements:
# We split each line in case there's a space for `-r`
session.install(*pkg.split())
session.install("-e", ".")

# Build JS packages
if yarn:
session.run("yarn", "--frozen-lockfile")