Skip to content

Add nox configuration file with environments for building documentation and running mypy - #2654

Merged
namurphy merged 13 commits into
PlasmaPy:mainfrom
namurphy:nox-docs
May 2, 2024
Merged

namurphy merged 13 commits into
PlasmaPy:mainfrom
namurphy:nox-docs

Conversation

@namurphy

@namurphy namurphy commented Apr 30, 2024 •

Copy link
Copy Markdown
Member

Description

This PR adds noxfile.py, which is a configuration file for nox. So far it includes testing environments for building docs and running mypy. After installing nox and uv, the environments can be run with commands like nox -e docs or nox -e mypy in the top-level directory of the repository.

Motivation and context

We currently use tox as our test runner. The configuration for tox is given in tox.ini. I've personally found tox.ini to be incredibly difficult to parse and understand.

nox is a test runner that was originally inspired by tox. Unlike tox, the configuration file for nox is a Python file: noxfile.py. In my limited experience, setting up and modifying test environments defined in noxfile.py has been considerably less difficult than doing the same in tox.ini.

This PR is only to add noxfile.py without adding it to the CI suite and without removing anything from tox.ini. Subsequent steps include:

  • Adding environments for running pytest, including with coverage
  • Adding an environment for regenerating requirements files (should wait until after Update requirements setup #2650 is resolved)
  • Switching GitHub Actions to use the nox environments instead of tox. (This ideally would be done incrementally.)
  • Updating the testing guide to reflect usage of nox instead of tox
  • Removing tox.ini

Related issues

#1734, #1735

@github-actions github-actions Bot added testing CI Related to continuous integration labels Apr 30, 2024
@namurphy namurphy added maintenance General updates to package infrastructure and removed CI Related to continuous integration labels Apr 30, 2024
@codecov

codecov Bot commented Apr 30, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.22%. Comparing base (cbaed0b) to head (e8af0e9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2654   +/-   ##
=======================================
  Coverage   95.22%   95.22%           
=======================================
  Files         103      103           
  Lines        9401     9401           
  Branches     2151     2151           
=======================================
  Hits         8952     8952           
  Misses        274      274           
  Partials      175      175           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions Bot added the CI Related to continuous integration label Apr 30, 2024
@github-actions github-actions Bot added the packaging Related to packaging or distribution label May 1, 2024
@namurphy
namurphy marked this pull request as ready for review May 1, 2024 22:01
@namurphy
namurphy requested a review from a team as a code owner May 1, 2024 22:01
@namurphy
namurphy requested review from ejohnson-96 and removed request for a team May 1, 2024 22:01
Comment thread noxfile.py
Comment on lines +12 to +22
sphinx_commands = (
"sphinx-build",
"docs/",
"docs/build/html",
"--nitpicky",
"--fail-on-warning",
"--keep-going",
)

html = ("-b", "html")
check_hyperlinks = ("-b", "linkcheck")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

📝 By defining the options into discrete groups like this, we can compose different environments to build the docs 📚 with different option sets ⚙️, which should make the commands more reusable. I suspect it'll be more maintainable too, since the commands that get reused are isolated from the details of the testing environment ↔️.

Comment thread conftest.py
settings.register_profile("debug", max_examples=10, verbosity=Verbosity.verbose)
settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default"))

collect_ignore = ["noxfile.py"]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

❔ I wasn't able to get pytest to ignore this file from within pyproject.toml, since I could only find options for ignoring directories rather than files.

It should also help to have a global pytest configuration file so that it works for both regular tests (in tests/) and doctests (in src/plasmapy/).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm 🤔 how strange

@ejohnson-96 ejohnson-96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@namurphy

namurphy commented May 2, 2024

Copy link
Copy Markdown
Member Author

Thank you for the reviews! 😸

@namurphy
namurphy merged commit 9e0e94a into PlasmaPy:main May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Related to continuous integration maintenance General updates to package infrastructure nox Related to the nox automation software packaging Related to packaging or distribution static type checking testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants