-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic testing automation against all version of Python using nox (#…
…2536) ### What This PR introduces basic support to run tests and examples against all supported version of Python (currently 3.8 to 3.11). Currently, running tests and `run_all.py` is supported. Usage: ``` nox --help nox -s tests nox -s run_all -- --save ``` For discoverability and convenience, I added a couple of `just` commands: ``` just py-tests-allpy just py-run-all-allpy --save ``` On the way, I added the capability to install example requirements to `run_all.py`: ``` python scripts/run_all.py --install-requirements ``` Decisions: - I used [nox](https://nox.thea.codes/en/stable/). The alternative is the older, more widespread [tox](https://tox.wiki/en/latest/). Reasons: `noxfile.py` is an actual Python script (as are most of our scripts already) and `nox` is battle-tested enough to be used in some large projects, including pip itself. - Nox is best installed globally on the dev machine (as it manages its own venvs for running stuff). I updated `setup_dev.sh` accordingly, by installing `pipx` using the OS package manager, and then using pipx to install nox. (This is The Right Way™️ to globally install Python CLIs.) Note: this requires all version of python to be installed and available on the dev machine. Can't recommend MacPorts enough: `sudo port install python38 python39 python310 python311`. Relates to: - #2445 ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) <!-- This line will get updated when the PR build summary job finishes. --> PR Build Summary: https://build.rerun.io/pr/2536 <!-- pr-link-docs:start --> Docs preview: https://rerun.io/preview/2d89edf/docs Examples preview: https://rerun.io/preview/2d89edf/examples <!-- pr-link-docs:end --> --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
- Loading branch information
Showing
5 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ screenshot*.png | |
|
||
# Web demo app build | ||
web_demo | ||
|
||
.nox/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Nox sessions. | ||
This file is used by `nox` to run tests and examples against multiple Python versions. | ||
See: http://nox.thea.codes | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import nox # type: ignore | ||
|
||
|
||
@nox.session(python=["3.8", "3.9", "3.10", "3.11"]) | ||
def tests(session: nox.Session) -> None: | ||
"""Run the Python test suite""" | ||
session.install("-r", "rerun_py/requirements-build.txt") | ||
session.install("./rerun_py") | ||
session.run("just", "py-test", external=True) | ||
|
||
|
||
@nox.session(python=["3.8", "3.9", "3.10", "3.11"]) | ||
def run_all(session: nox.Session) -> None: | ||
"""Run all examples through the run_all.py script (pass args with: "-- <args>")""" | ||
# Note: the run_all.py scripts installs all dependencies itself. In particular, we can install from | ||
# examples/python/requirements.txt because it includes pyrealsense2, which is not available for mac. | ||
session.run("python", "scripts/run_all.py", "--install-requirements", *session.posargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters