From bc34609ea2a18349c9c2a874e6116f3a618aba81 Mon Sep 17 00:00:00 2001 From: Raoul Wols Date: Thu, 4 Jun 2026 13:53:26 +0200 Subject: [PATCH] Switch to using the `nox` tool for driving linting and testing --- .github/workflows/ci.yml | 11 +++-------- .github/workflows/publish.yml | 6 ++---- .gitignore | 2 ++ README.md | 17 +++++++++++++---- noxfile.py | 11 +++++++++++ pyproject.toml | 4 +++- requirements.txt | 1 + 7 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 noxfile.py create mode 100644 requirements.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c1477c..a3e53d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,11 +24,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install . - python -m pip install ruff - - name: Lint - run: python -m ruff check . - - name: Test with python unittest - run: python -m unittest + run: python -m pip --disable-pip-version-check install nox + - name: Lint & Test + run: nox diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 173ce52..c404948 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ name: Upload Python Package on: release: - types: [ published ] + types: [published] permissions: contents: read @@ -25,9 +25,7 @@ jobs: with: python-version: '3.9' - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build + run: python -m pip --disable-pip-version-check install build - name: Build package run: python -m build - name: Publish package diff --git a/.gitignore b/.gitignore index 552e8ad..50e6e0b 100644 --- a/.gitignore +++ b/.gitignore @@ -44,7 +44,9 @@ pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ +.nox/ .tox/ +.ruff_cache/ .coverage .coverage.* .cache diff --git a/README.md b/README.md index 0a41400..6a70551 100644 --- a/README.md +++ b/README.md @@ -195,18 +195,27 @@ with \ ``` ## Documentation + The full documentation is available in the `docs` folder with a readable version on [Read the Docs](https://trsfile.readthedocs.io/). ## Contributing -### Testing -The library supports Python `unittest` module and the tests can be executed with the following command: -``` -python -m unittest +Anyone is free to open a pull request. + +### Testing / Developing + +The library has tests and a linter has been set up for it. Both can be run with the following command: + +```sh +nox ``` +Install the `nox` executable (in a virtual environment) using `python -m pip install -r ./requirements.txt`. + ### Creating Releases + We use Github Actions to publish packages to PYPy. Read the [Github docs on how to create a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) and trigger the publishing workflow: ## License + [BSD 3-Clause Clear License](https://choosealicense.com/licenses/bsd-3-clause-clear/) diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..74d8424 --- /dev/null +++ b/noxfile.py @@ -0,0 +1,11 @@ +import nox +import nox.project + + +@nox.session(reuse_venv=True) +def lint(session: nox.Session) -> None: + requirements = nox.project.load_toml("pyproject.toml")["project"]["optional-dependencies"]["DEV"] + session.install(*requirements) + session.install("-e", ".") + session.run("ruff", "check") + session.run("python", "-m", "unittest", "discover") diff --git a/pyproject.toml b/pyproject.toml index 9fe2e6a..4dffc05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,10 +29,12 @@ dependencies = [ [project.optional-dependencies] DEV = [ + "m2r2", + "numpy", + "ruff", "sphinx", "sphinx-autobuild", "sphinx_rtd_theme", - "m2r2" ] [project.urls] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..816817c --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +nox