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

Replace Tox with Nox #861

Merged
merged 46 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3a1b2ac
Use nox
IvanIsCoding Apr 14, 2023
7e84def
Trying to fix nox
IvanIsCoding Apr 14, 2023
fb91487
Fix tests
IvanIsCoding Apr 14, 2023
2bbbb02
Minor items in lint
IvanIsCoding Apr 14, 2023
bff21e5
More nox details
IvanIsCoding Apr 14, 2023
a4c5773
Update Contributing.md
IvanIsCoding Apr 14, 2023
4967c9e
Add release notes
IvanIsCoding Apr 14, 2023
1b498d0
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Apr 14, 2023
1ac8aa8
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Jun 21, 2023
38584d3
Add scipy requirement to noxfile
IvanIsCoding Jun 21, 2023
d13a609
Merge branch 'main' into swap-nox-tox
IvanIsCoding Jun 23, 2023
891562f
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Sep 2, 2023
6f6e311
Move flake8 to pyproject.toml (against its will)
IvanIsCoding Sep 2, 2023
5dd0a7d
Revert RETWORKX_TEST_PRESERVE_IMAGES
IvanIsCoding Sep 2, 2023
9c8fd28
Running tox errors
IvanIsCoding Sep 2, 2023
afa4583
Capitalization
IvanIsCoding Sep 2, 2023
9cc214e
Try to make docs work
IvanIsCoding Sep 2, 2023
0582176
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Sep 12, 2023
01cee00
Edit error messages for tox
IvanIsCoding Sep 12, 2023
8a6109a
Add constraints to docs install
IvanIsCoding Sep 12, 2023
7290689
Include extras appropriately
IvanIsCoding Sep 12, 2023
eb62655
Add test_with_version
IvanIsCoding Sep 12, 2023
5451cc6
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Sep 17, 2023
dfe1cbe
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Sep 22, 2023
fb319da
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Oct 18, 2023
ddf2da8
Merge remote-tracking branch 'origin/main' into swap-nox-tox
IvanIsCoding Oct 18, 2023
28886d8
Switch lint to ruff
IvanIsCoding Oct 18, 2023
f2e1353
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Jan 9, 2024
206614b
Port some changes from nox to tox
IvanIsCoding Jan 9, 2024
6cdaf49
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Jan 11, 2024
e0cdfc6
Remove file that should not be there
IvanIsCoding Jan 13, 2024
a625ef8
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Jan 13, 2024
27a8f1f
Merge branch 'main' into swap-nox-tox
IvanIsCoding Jan 17, 2024
c9af9cc
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Jan 21, 2024
7701174
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Jan 21, 2024
6a87159
Incorporate recent changes into Nox
IvanIsCoding Jan 21, 2024
6112415
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Jan 24, 2024
703724f
Fix Noxfile
IvanIsCoding Jan 26, 2024
25f02ff
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Jan 28, 2024
62c7fef
Merge remote-tracking branch 'upstream/main' into swap-nox-tox
IvanIsCoding Mar 23, 2024
74eacd4
Revert tox usage
IvanIsCoding Mar 23, 2024
d980f26
Include Python 3.12
IvanIsCoding Mar 23, 2024
0f4b22a
Faster lint phase
IvanIsCoding Mar 23, 2024
4235ac1
Reuse install code
IvanIsCoding Mar 23, 2024
70e63de
Restore tox.ini and add print to the end of commands
mtreinish Mar 28, 2024
9d58cd8
Merge branch 'main' into swap-nox-tox
mtreinish Mar 28, 2024
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: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
IvanIsCoding marked this conversation as resolved.
Show resolved Hide resolved
# E125 is deliberately excluded. See https://github.com/jcrocholl/pep8/issues/126
# E123 skipped because it is ignored by default in the default pep8
# E129 skipped because it is too limiting when combined with other rules
# E711 skipped because sqlalchemy filter() requires using == instead of is
# max-line-length, E203, W503 are added for black compatibility
max-line-length = 110
ignore = E125,E123,E129,E711
extend-ignore = E203, W503
exclude = .venv,.git,.nox,dist,doc,*egg,build
2 changes: 1 addition & 1 deletion .github/workflows/docs_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U virtualenv setuptools wheel tox
pip install -U virtualenv setuptools wheel nox
sudo apt-get install graphviz pandoc
- name: Build and publish
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U virtualenv setuptools wheel tox
pip install -U virtualenv setuptools wheel nox
sudo apt-get install graphviz pandoc
- name: Build and publish
env:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ jobs:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.platform.rust-target }}
- name: 'Install dependencies'
run: python -m pip install --upgrade tox
run: python -m pip install --upgrade nox
- name: 'Install binary dependencies'
run: sudo apt-get install -y graphviz
if: runner.os == 'Linux'
- name: 'Run tests'
run: tox -epy
run: nox -e test
tests_stubs:
needs: [tests]
name: python-stubs-${{ matrix.python-version }}
Expand All @@ -103,9 +103,9 @@ jobs:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: 'Install dependencies'
run: python -m pip install --upgrade tox
run: python -m pip install --upgrade nox
- name: 'Run rustworkx stub tests'
run: tox -estubs
run: nox -e stubs
tests_retworkx_compat:
needs: [build_lint]
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} ${{ matrix.msrv }}
Expand Down Expand Up @@ -205,9 +205,9 @@ jobs:
- name: Install binary deps
run: sudo apt-get install -y graphviz
- name: Install deps
run: pip install -U tox
run: pip install -U nox
- name: Build Docs
run: tox -edocs
run: nox -e docs
- uses: actions/upload-artifact@v3
with:
name: html_docs
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ docs/apiref/
docs/source/apiref/
docs/source/stubs/
.tox/
.nox/
retworkx/*.so
retworkx/*pyd
*.stestr/
Expand Down
46 changes: 23 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ also run successfully. Before you open a new pull request for your change,
you'll want to run the test suite locally.

The easiest way to run the test suite is to use
[**tox**](https://tox.readthedocs.io/en/latest/#). You can install tox
with pip: `pip install -U tox`. Tox provides several advantages, but the
[**Nox**](https://nox.thea.codes/en/stable/). You can install Nox
with pip: `pip install -U nox`. Nox provides several advantages, but the
biggest one is that it builds an isolated virtualenv for running tests. This
means it does not pollute your system python when running. However, by default
tox will recompile rustworkx from source every time it is run even if there
Nox will recompile rustworkx from source every time it is run even if there
are no changes made to the rust code. To avoid this you can use the
`--skip-pkg-install` package if you'd like to rerun tests without recompiling.
IvanIsCoding marked this conversation as resolved.
Show resolved Hide resolved
Note, you only want to use this flag if you recently ran tox and there are no
Note, you only want to use this flag if you recently ran Nox and there are no
rust code (or packaged python code) changes to the repo since then. Otherwise
the rustworkx package tox installs in it's virtualenv will be out of date (or
the rustworkx package Nox installs in it's virtualenv will be out of date (or
missing).

Note, if you run tests outside of tox that you can **not** run the tests from
Note, if you run tests outside of Nox that you can **not** run the tests from
the root of the repo, this is because rustworkx packaging shim will conflict
with imports from rustworkx the installed version of rustworkx (which contains
the compiled extension).
Expand All @@ -131,7 +131,7 @@ the compiled extension).

If you just want to run a subset of tests you can pass a selection regex to the
test runner. For example, if you want to run all tests that have "dag" in the
test id you can run: `tox -epy -- dag`. You can pass arguments directly to the
test id you can run: `nox -e test -- dag`. You can pass arguments directly to the
IvanIsCoding marked this conversation as resolved.
Show resolved Hide resolved
test runner after the bare `--`. To see all the options on test selection you
can refer to the stestr manual:

Expand All @@ -142,42 +142,42 @@ you can do this faster with the `-n`/`--no-discover` option. For example:

to run a module:
```
tox -epy -- -n test_max_weight_matching
nox -e test -- -n test_max_weight_matching
```
or to run the same module by path:
```
tox -epy -- -n graph/test_nodes.py
nox -e test -- -n graph/test_nodes.py
```
to run a class:
```
tox -epy -- -n graph.test_nodes.TestNodes
nox -e test -- -n graph.test_nodes.TestNodes
```
to run a method:
```
tox -epy -- -n graph.test_nodes.TestNodes.test_no_nodes
nox -e test -- -n graph.test_nodes.TestNodes.test_no_nodes
```

It's important to note that tox will be running from the `tests/` directory in
It's important to note that Nox will be running from the `tests/` directory in
the repo, so any paths you pass to the test runner via path need to be relative
to that directory.

#### Visualization Tests

When running the visualization tests, each test will generate a visualization
and only fail if an exception is raised by the call. Each test saves the output
image to the current working directory (which if running tests with `tox` is
image to the current working directory (which if running tests with `nox` is
`tests/`) to ensure the generated image is usable. However to not clutter the
system each test cleans up this generated image and by default a test run does
not include any way to view the images from the visualization tests.

If you want to inspect the output from the visualization tests (which is common
if you're working on visualizations) you can set the
`RETWORKX_TEST_PRESERVE_IMAGES` environment variable to any value and this will
`RUSTWORKX_TEST_PRESERVE_IMAGES` environment variable to any value and this will
IvanIsCoding marked this conversation as resolved.
Show resolved Hide resolved
skip the cleanup. This will enable you to look at the output image and ensure the
visualization is correct. For example, running:

```
RETWORKX_TEST_PRESERVE_IMAGES=1 tox -epy
RUSTWORKX_TEST_PRESERVE_IMAGES=1 nox -e test
```

will run the visualization tests and preserve the generated image files after
Expand Down Expand Up @@ -230,25 +230,25 @@ cargo clippy
Python is used primarily for tests and some small pieces of packaging
and namespace configuration code in the actual library.
[black](https://github.com/psf/black) and [flake8](https://flake8.pycqa.org/en/latest/) are used to enforce consistent
style in the python code in the repository. You can run them via tox using:
style in the python code in the repository. You can run them via Nox using:

```bash
tox -elint
nox -e lint
```

This will also run `cargo fmt` in check mode to ensure that you ran `cargo fmt`
and will fail if the Rust code doesn't conform to the style rules.

If black returns a code formatting error you can run `tox -eblack` to automatically
If black returns a code formatting error you can run `nox -e black` to automatically
update the code formatting to conform to the style.

### Building documentation

Just like with tests building documentation is done via tox. This will handle
Just like with tests building documentation is done via Nox. This will handle
compiling rustworkx, installing the python dependencies, and then building the
documentation in an isolated venv. You can run just the docs build with:
```
tox -edocs
nox -e docs
```
which will output the html rendered documentation in `docs/build/html` which
you can view locally in a web browser.
Expand Down Expand Up @@ -281,10 +281,10 @@ They contain annotated signatures for Python functions, stripped of their implem
While this step is optional, it is very helpful for end-users. Adding annotations lets users type check
their code with [mypy](http://mypy-lang.org/), which can be helpful for finding bugs.

Just like with tests for the code, annotations are also tested via tox.
Just like with tests for the code, annotations are also tested via Nox.

```
tox -estubs
Nox -e stubs
```

### Release Notes
Expand Down Expand Up @@ -411,7 +411,7 @@ it has been tagged::

Building the release notes is part of the standard rustworkx documentation
builds. To check what the rendered html output of the release notes will look
like for the current state of the repo you can run: `tox -edocs` which will
like for the current state of the repo you can run: `nox -e docs` which will
build all the documentation into `docs/_build/html` and the release notes in
particular will be located at `docs/_build/html/release_notes.html`

Expand Down
62 changes: 62 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import nox

nox.options.reuse_existing_virtualenvs = True
nox.options.stop_on_first_error = True

deps = [
"setuptools-rust",
"fixtures",
"testtools>=2.5.0",
"networkx>=2.5",
"stestr",
]

extras = [
"mpl",
"graphviz",
]
IvanIsCoding marked this conversation as resolved.
Show resolved Hide resolved

@nox.session(python=["3"])
IvanIsCoding marked this conversation as resolved.
Show resolved Hide resolved
def test(session):
session.install(*deps)
session.install(".", "-c", "constraints.txt")
session.chdir("tests")
session.run("python", "-m", "stestr", "run", *session.posargs)

@nox.session(python=["3"])
def lint(session):
session.install(*deps)
session.install(".", "-c", "constraints.txt")
session.install("black~=22.0", "flake8", "setuptools-rust")
session.run("black", "--check", "--diff", "rustworkx", "tests", "retworkx", *session.posargs)
session.run("flake8", "--per-file-ignores='rustworkx/__init__.py':F405,F403", "setup.py", "rustworkx", "retworkx", ".")
session.run("cargo", "fmt", "--all", "--", "--check")
session.run("python", "tools/find_stray_release_notes.py")

@nox.session(python=["3"])
def docs(session):
session.install(*deps)
session.install(".", "-c", "constraints.txt")
session.install("-r", "docs/source/requirements.txt")
session.run("python", "-m", "ipykernel", "install", "--user")
session.run("jupyter", "kernelspec", "list")
session.chdir("docs")
session.run("sphinx-build", "-W", "-d", "build/.doctrees", "-b", "html", "source", "build/html", *session.posargs)

@nox.session(python=["3"])
def black(session):
session.install("black~=22.0")
session.run("black", "rustworkx", "tests", "retworkx", *session.posargs)

@nox.session(python=["3"])
def stubs(session):
session.install(*deps)
session.install(".", "-c", "constraints.txt")
session.install("mypy==1.0.1")
session.chdir("tests")
session.run("python", "-m", "mypy.stubtest", "--concise", "--ignore-missing-stub", "rustworkx.rustworkx")

@nox.session(python=["3"])
def black(session):
session.install("black~=22.0")
session.run("black", "rustworkx", "tests", "retworkx", *session.posargs)
6 changes: 6 additions & 0 deletions releasenotes/notes/swap-nox-tox-dea2bb14c400641c.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
other:
- |
Switched automated testing environment from
Tox to `Nox <https://nox.thea.codes/en/stable/>`__. This
change should not impact the end-user
2 changes: 1 addition & 1 deletion tools/deploy_documentation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sudo apt-get install -y ./rclone.deb
RCLONE_CONFIG_PATH=$(rclone config file | tail -1)

# Build the documentation.
tox -edocs
nox -e docs

echo "show current dir: "
pwd
Expand Down
2 changes: 1 addition & 1 deletion tools/deploy_documentation_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sudo apt-get install -y ./rclone.deb
RCLONE_CONFIG_PATH=$(rclone config file | tail -1)

# Build the documentation.
RETWORKX_DEV_DOCS=1 tox -edocs
RETWORKX_DEV_DOCS=1 nox -e docs

echo "show current dir: "
pwd
Expand Down
79 changes: 0 additions & 79 deletions tox.ini

This file was deleted.