Skip to content

Commit d5f782c

Browse files
thirtytwobitsScott DixonCopilot
authored
Thirtytwobits/issue374 (#392)
Switching to nox and modernizing the nunavut python packaging. --------- Co-authored-by: Scott Dixon <thirtytwobits@Scotts-MacBook-Pro.local> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5e72609 commit d5f782c

16 files changed

Lines changed: 549 additions & 406 deletions

File tree

.devcontainer/toxic/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
]
2121
}
2222
},
23-
"postCreateCommand": "git submodule update --init --recursive && tox -e local"
23+
"postCreateCommand": "git submodule update --init --recursive && nox -s local"
2424
}

.github/workflows/release.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ jobs:
1313
- uses: actions/checkout@v4
1414
with:
1515
submodules: true
16+
- name: setup nox
17+
run: pip install nox
1618
- name: version-check
1719
# Fails the release if the release-tag doesn't match the Nunavut version at that tag.
1820
run: |
1921
python3 ./src/nunavut/_version.py -v --fail-on-mismatch --tag=${{ github.ref }}
2022
- name: lint
21-
run: tox -e lint
23+
run: nox -s lint
2224
- name: test-nnvg
23-
run: tox -e py311-nnvg
25+
run: nox -s nnvg-3.11
2426
- name: test-doctest
25-
run: tox -e py311-doctest,py311-rstdoctest
27+
run: nox -s doctest-3.11 rstdoctest-3.11
2628
- name: test-pytest
27-
run: tox -e py311-test
29+
run: nox -s test-3.11
2830
- name: package
29-
run: tox -e package
31+
run: nox -s package
3032
- name: upload
3133
run: |
3234
pip3 install twine
33-
twine upload -u __token__ -p ${{ secrets.PYPI_PASSWORD }} .tox/package/dist/*
35+
twine upload -u __token__ -p ${{ secrets.PYPI_PASSWORD }} .nox/package/tmp/dist/*

.github/workflows/test.yml

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,35 @@ jobs:
1818
- uses: actions/checkout@v4
1919
with:
2020
submodules: true
21+
- name: setup nox
22+
run: pip install nox
2123
- name: lint
22-
run: tox -e lint
24+
run: nox -s lint
2325
- name: test-nnvg
24-
run: tox -e py311-nnvg
26+
run: nox -s nnvg-3.11
2527
- name: test-doctest
26-
run: tox -e py311-doctest,py311-rstdoctest
28+
run: nox -s doctest-3.11 rstdoctest-3.11
2729
- name: test-pytest
28-
run: tox -e py311-test
30+
run: nox -s test-3.11
2931
- name: test-report
30-
run: tox -e report
32+
run: nox -s report
3133
- name: package
32-
run: tox -e package
34+
run: nox -s package
3335
- name: upload-coverage-reports
3436
uses: actions/upload-artifact@v4
3537
with:
3638
name: coverage-reports
37-
path: .tox/report/tmp/*
39+
path: .nox/report/tmp/*
3840
- name: upload-xunit-results
3941
uses: actions/upload-artifact@v4
4042
with:
4143
name: xunit-results
42-
path: .tox/py311-test/tmp/xunit-result.xml
44+
path: .nox/test-3-11/tmp/xunit-result.xml
4345
- name: upload-package
4446
uses: actions/upload-artifact@v4
4547
with:
4648
name: pypi-package
47-
path: .tox/package/dist/*
49+
path: .nox/package/tmp/dist/*
4850

4951
sonar:
5052
runs-on: ubuntu-latest
@@ -58,18 +60,18 @@ jobs:
5860
uses: actions/download-artifact@v4
5961
with:
6062
name: coverage-reports
61-
path: .tox/report/tmp/
63+
path: .nox/report/tmp/
6264
- name: download-xunit-results
6365
uses: actions/download-artifact@v4
6466
with:
6567
name: xunit-results
66-
path: .tox/py311-test/tmp/
68+
path: .nox/test-3-11/tmp/
6769
- name: set-environment
6870
run: |
6971
echo NUNAVUT_MAJOR_MINOR_VERSION=$(./src/nunavut/_version.py --major-minor-only) >> $GITHUB_ENV
70-
- name: verify tox artifacts
72+
- name: verify nox artifacts
7173
run: ls -R
72-
working-directory: .tox
74+
working-directory: .nox
7375
- name: report-release
7476
if: ${{ github.event_name != 'pull_request' }}
7577
uses: SonarSource/sonarqube-scan-action@v4.2.1
@@ -82,8 +84,8 @@ jobs:
8284
-Dsonar.buildString=${{ env.GITHUB_RUN_ID }}
8385
-Dsonar.projectVersion=${{ env.NUNAVUT_MAJOR_MINOR_VERSION }}
8486
-Dsonar.python.version=python3.11
85-
-Dsonar.python.coverage.reportPaths=.tox/report/tmp/coverage.xml
86-
-Dsonar.python.xunit.reportPath=.tox/py311-test/tmp/xunit-result.xml
87+
-Dsonar.python.coverage.reportPaths=.nox/report/tmp/coverage.xml
88+
-Dsonar.python.xunit.reportPath=.nox/test-3-11/tmp/xunit-result.xml
8789
- name: report-pr
8890
if: ${{ github.event_name == 'pull_request' }}
8991
uses: SonarSource/sonarqube-scan-action@v4.2.1
@@ -96,8 +98,8 @@ jobs:
9698
-Dsonar.buildString=${{ env.GITHUB_RUN_ID }}
9799
-Dsonar.projectVersion=${{ env.NUNAVUT_MAJOR_MINOR_VERSION }}
98100
-Dsonar.python.version=python3.11
99-
-Dsonar.python.coverage.reportPaths=.tox/report/tmp/coverage.xml
100-
-Dsonar.python.xunit.reportPath=.tox/py311-test/tmp/xunit-result.xml
101+
-Dsonar.python.coverage.reportPaths=.nox/report/tmp/coverage.xml
102+
-Dsonar.python.xunit.reportPath=.nox/test-3-11/tmp/xunit-result.xml
101103
102104
compat-test-python3-windows-and-mac:
103105
strategy:
@@ -114,10 +116,10 @@ jobs:
114116
uses: actions/setup-python@v5
115117
with:
116118
python-version: 3.${{ matrix.python3-version }}
117-
- name: setup tox
118-
run: pip3 install tox
119+
- name: setup nox
120+
run: pip3 install nox
119121
- name: python3.${{ matrix.python3-version }} test
120-
run: tox -e py3${{ matrix.python3-version }}-nnvg,py3${{ matrix.python3-version }}-test
122+
run: nox -s nnvg-3.${{ matrix.python3-version }} test-3.${{ matrix.python3-version }}
121123

122124
compat-test-python3-ubuntu:
123125
strategy:
@@ -130,8 +132,10 @@ jobs:
130132
- uses: actions/checkout@v4
131133
with:
132134
submodules: true
135+
- name: setup nox
136+
run: pip install nox
133137
- name: python3.${{ matrix.python3-version }} test
134-
run: tox -e py3${{ matrix.python3-version }}-nnvg,py3${{ matrix.python3-version }}-test
138+
run: nox -s nnvg-3.${{ matrix.python3-version }} test-3.${{ matrix.python3-version }}
135139

136140
language-verification-c-cpp:
137141
runs-on: ubuntu-latest

.pylintrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[MAIN]
2+
ignore-paths = .*/(jinja2|markupsafe)/.*
3+
source-roots = src
4+
5+
[FORMAT]
6+
max-line-length = 120
7+
8+
[DESIGN]
9+
max-args = 8
10+
max-attributes = 12
11+
min-public-methods = 0
12+
13+
[MESSAGES CONTROL]
14+
disable = no-else-return,invalid-name,too-many-positional-arguments

.vscode/settings.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"python.testing.pytestEnabled": true,
55
"python.testing.pytestArgs": ["-vv"],
66
"pylint.args": [
7-
"--rcfile=${workspaceFolder}/tox.ini"
7+
"--rcfile=${workspaceFolder}/.pylintrc"
88
],
99
"isort.args": [
1010
"--line-length=120"
@@ -15,7 +15,7 @@
1515
],
1616
"mypy-type-checker.args": [
1717
"--config-file",
18-
"${workspaceFolder}/tox.ini"
18+
"${workspaceFolder}/pyproject.toml"
1919
],
2020
"mypy-type-checker.importStrategy": "fromEnvironment",
2121
"flake8.args": [
@@ -142,5 +142,9 @@
142142
"sonarlint.connectedMode.project": {
143143
"connectionId": "opencyphal",
144144
"projectKey": "OpenCyphal_nunavut"
145-
}
145+
},
146+
"python-envs.workspaceSearchPaths": [
147+
"./**/.venv",
148+
"./.nox/local"
149+
]
146150
}

CONTRIBUTING.rst

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,22 @@ will kickoff and do the rest for you.
2828
Tools
2929
************************************************
3030

31-
tox devenv -e local
31+
nox -s local
3232
================================================
3333

34-
I highly recommend using the local tox environment when doing python development. It'll save you hours
34+
I highly recommend using the local nox session when doing python development. It'll save you hours
3535
of lost productivity the first time it keeps you from pulling in an unexpected dependency from your
36-
global python environment. You can install tox from brew on osx or apt-get on GNU/Linux. I'd
36+
global python environment. You can install nox from brew on osx or pip on any platform. I'd
3737
recommend the following environment for vscode::
3838

3939
git submodule update --init --recursive
40-
tox devenv -e local
41-
source venv/bin/activate
40+
pip install nox
41+
nox -s local
42+
source .nox/local/bin/activate
4243

4344
On Windows that last line is instead::
4445

45-
./venv/Scripts/activate
46+
.\.nox\local\Scripts\activate
4647

4748
cmake
4849
================================================
@@ -58,15 +59,16 @@ To use vscode you'll need:
5859

5960
1. vscode
6061
2. install vscode command line (`Shell Command: Install`)
61-
3. tox
62+
3. nox
6263
4. cmake (and an available GCC or Clang toolchain, or Docker to use our toolchain-as-container)
6364

6465
Do::
6566

6667
cd path/to/nunavut
6768
git submodule update --init --recursive
68-
tox devenv -e local
69-
source venv/bin/activate
69+
pip install nox
70+
nox -s local
71+
source .nox/local/bin/activate
7072
code .
7173

7274
Then install recommended extensions.
@@ -75,15 +77,15 @@ Then install recommended extensions.
7577
Running The Tests
7678
************************************************
7779

78-
To run the full suite of `tox`_ tests locally you'll need docker. Once you have docker installed
80+
To run the full suite of `nox`_ tests locally you'll need docker. Once you have docker installed
7981
and running do::
8082

8183
git submodule update --init --recursive
8284
docker pull ghcr.io/opencyphal/toxic:tx22.4.3
83-
docker run --rm -v $PWD:/repo ghcr.io/opencyphal/toxic:tx22.4.3 tox
85+
docker run --rm -v $PWD:/repo ghcr.io/opencyphal/toxic:tx22.4.3 /bin/sh -c "pip install nox && nox"
8486

8587
To run a limited suite using only locally available interpreters directly on your host machine,
86-
skip the docker invocations and use ``tox run -s``.
88+
skip the docker invocations and use ``nox``.
8789

8890
To run the language verification build you'll need to use a different docker container::
8991

@@ -210,13 +212,13 @@ Building The Docs
210212
************************************************
211213

212214
We rely on `read the docs`_ to build our documentation from github but we also verify this build
213-
as part of our tox build. This means you can view a local copy after completing a full, successful
215+
as part of our nox build. This means you can view a local copy after completing a full, successful
214216
test run (See `Running The Tests`_) or do
215-
:code:`docker run --rm -t -v $PWD:/repo ghcr.io/opencyphal/toxic:tx22.4.3 /bin/sh -c "tox run -e docs"` to build
216-
the docs target. You can open the index.html under ``.tox_{host platform}/docs/tmp/index.html`` or run a local
217+
:code:`docker run --rm -t -v $PWD:/repo ghcr.io/opencyphal/toxic:tx22.4.3 /bin/sh -c "pip install nox && nox -s docs"` to build
218+
the docs target. You can open the index.html under ``.nox/docs/tmp/index.html`` or run a local
217219
web-server::
218220

219-
python3 -m http.server --directory .tox_{host platform}/docs/tmp &
221+
python3 -m http.server --directory .nox/docs/tmp &
220222
open http://localhost:8000/docs/index.html
221223

222224
Of course, you can just use `Visual Studio Code`_ to build and preview the docs using
@@ -227,25 +229,25 @@ Of course, you can just use `Visual Studio Code`_ to build and preview the docs
227229
Coverage and Linting Reports
228230
************************************************
229231

230-
We publish the results of our coverage data to `sonarcloud`_ and the tox build will fail for any mypy
231-
or black errors but you can view additional reports locally under the :code:`.tox_{host platform}` dir.
232+
We publish the results of our coverage data to `sonarcloud`_ and the nox build will fail for any mypy
233+
or black errors but you can view additional reports locally under the :code:`.nox` dir.
232234

233235
Coverage
234236
================================================
235237

236-
We generate a local html coverage report. You can open the index.html under .tox_{host platform}/report/tmp
238+
We generate a local html coverage report. You can open the index.html under .nox/report/tmp
237239
or run a local web-server::
238240

239-
python -m http.server --directory .tox_{host platform}/report/tmp &
241+
python -m http.server --directory .nox/report/tmp &
240242
open http://localhost:8000/index.html
241243

242244
Mypy
243245
================================================
244246

245247
At the end of the mypy run we generate the following summaries:
246248

247-
- .tox_{host platform}/mypy/tmp/mypy-report-lib/index.txt
248-
- .tox_{host platform}/mypy/tmp/mypy-report-script/index.txt
249+
- .nox/lint/tmp/mypy-report-lib/index.txt
250+
- .nox/lint/tmp/mypy-report-script/index.txt
249251

250252
************************************************
251253
Nunavut Verification Suite
@@ -326,7 +328,7 @@ three variables you can set in your environment or pass into cmake if using cmak
326328
All other options set when generating code are provided by setting ``NUNAVUT_EXTRA_GENERATOR_ARGS`` in your environment.
327329

328330
.. _`read the docs`: https://readthedocs.org/
329-
.. _`tox`: https://tox.readthedocs.io/en/latest/
331+
.. _`nox`: https://nox.thea.codes/en/stable/
330332
.. _`sonarcloud`: https://sonarcloud.io/dashboard?id=OpenCyphal_nunavut
331333
.. _`OpenCyphal website`: http://opencyphal.org
332334
.. _`OpenCyphal forum`: https://forum.opencyphal.org

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Nunavut: DSDL transpiler
33
################################################
44

55
+--------------------------------+-----------------------------------+
6-
| tox build (main) | |badge_build|_ |
6+
| nox build (main) | |badge_build|_ |
77
+--------------------------------+-----------------------------------+
88
| static analysis | |badge_analysis|_ |badge_issues|_ |
99
+--------------------------------+-----------------------------------+
@@ -222,9 +222,9 @@ Nunavut is part of the OpenCyphal project:
222222
:alt: Documentation Status
223223
.. _badge_docs: https://nunavut.readthedocs.io/en/latest/?badge=latest
224224

225-
.. |badge_build| image:: https://github.com/OpenCyphal/nunavut/actions/workflows/test_and_release.yml/badge.svg
225+
.. |badge_build| image:: https://github.com/OpenCyphal/nunavut/actions/workflows/test.yml/badge.svg
226226
:alt: Build status
227-
.. _badge_build: https://github.com/OpenCyphal/nunavut/actions/workflows/test_and_release.yml
227+
.. _badge_build: https://github.com/OpenCyphal/nunavut/actions/workflows/test.yml
228228

229229
.. |badge_pypi_support| image:: https://img.shields.io/pypi/pyversions/nunavut.svg
230230
:alt: Supported Python Versions

0 commit comments

Comments
 (0)