From 765a3851de15b87c7cc9fb88b63c7bb99e0c2cf7 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 17 Jan 2025 15:50:58 -0500 Subject: [PATCH] Switch to nox (#954) --- .github/workflows/ci.yml | 72 ++++++++++++++++++++-------------------- MANIFEST.in | 2 +- noxfile.py | 42 +++++++++++++++++++++++ pyproject.toml | 3 ++ tox.ini | 43 ------------------------ 5 files changed, 82 insertions(+), 80 deletions(-) create mode 100644 noxfile.py delete mode 100644 tox.ini diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09844a2d..ac216da0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,9 +14,9 @@ jobs: fail-fast: false matrix: PYTHON: - - {VERSION: "3.8", TOXENV: "py38"} - - {VERSION: "3.13", TOXENV: "py313"} - - {VERSION: "3.13t", TOXENV: "py313"} + - {VERSION: "3.8", NOXSESSION: "tests"} + - {VERSION: "3.13", NOXSESSION: "tests"} + - {VERSION: "3.13t", NOXSESSION: "tests"} MACOS: - macos-13 - macos-latest @@ -38,10 +38,10 @@ jobs: ~/.cargo/git/db/ src/_bcrypt/target/ key: ${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - run: pip install tox - - run: tox + - run: pip install nox + - run: nox -v env: - TOXENV: ${{ matrix.PYTHON.TOXENV }} + NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }} CARGO_TARGET_DIR: ${{ format('{0}/src/_bcrypt/target/', github.workspace) }} windows: @@ -52,9 +52,9 @@ jobs: - {ARCH: 'x86', WINDOWS: 'win32', RUST_TRIPLE: 'i686-pc-windows-msvc'} - {ARCH: 'x64', WINDOWS: 'win64', RUST_TRIPLE: 'x86_64-pc-windows-msvc'} PYTHON: - - {VERSION: "3.8", TOXENV: "py38"} - - {VERSION: "3.13", TOXENV: "py313"} - - {VERSION: "3.13t", TOXENV: "py313"} + - {VERSION: "3.8", NOXSESSION: "tests"} + - {VERSION: "3.13", NOXSESSION: "tests"} + - {VERSION: "3.13t", NOXSESSION: "tests"} name: "Python ${{ matrix.PYTHON.VERSION }} on ${{ matrix.WINDOWS.WINDOWS }}" steps: - uses: actions/checkout@v4.2.2 @@ -76,32 +76,32 @@ jobs: src/_bcrypt/target/ key: ${{ runner.os }}-${{ matrix.WINDOWS.ARCH }}-${{ steps.setup-python.outputs.python-version }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - run: pip install tox - - run: tox + - run: pip install nox + - run: nox -v env: - TOXENV: ${{ matrix.PYTHON.TOXENV }} + NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }} CARGO_TARGET_DIR: ${{ format('{0}/src/_bcrypt/target/', github.workspace) }} linux: runs-on: ubuntu-22.04 strategy: matrix: PYTHON: - - {VERSION: "3.13", TOXENV: "pep8,packaging"} - - {VERSION: "3.13", TOXENV: "mypy"} - - {VERSION: "3.8", TOXENV: "py38"} - - {VERSION: "3.9", TOXENV: "py39"} - - {VERSION: "3.10", TOXENV: "py310"} - - {VERSION: "3.11", TOXENV: "py311"} - - {VERSION: "3.12", TOXENV: "py312"} - - {VERSION: "3.13", TOXENV: "py313"} - - {VERSION: "3.13t", TOXENV: "py313"} - - {VERSION: "pypy-3.9", TOXENV: "pypy3"} - - {VERSION: "pypy-3.10", TOXENV: "pypy3"} + - {VERSION: "3.13", NOXSESSION: "pep8,packaging"} + - {VERSION: "3.13", NOXSESSION: "mypy"} + - {VERSION: "3.8", NOXSESSION: "tests"} + - {VERSION: "3.9", NOXSESSION: "tests"} + - {VERSION: "3.10", NOXSESSION: "tests"} + - {VERSION: "3.11", NOXSESSION: "tests"} + - {VERSION: "3.12", NOXSESSION: "tests"} + - {VERSION: "3.13", NOXSESSION: "tests"} + - {VERSION: "3.13t", NOXSESSION: "tests"} + - {VERSION: "pypy-3.9", NOXSESSION: "tests"} + - {VERSION: "pypy-3.10", NOXSESSION: "tests"} # MSRV - - {VERSION: "3.13", TOXENV: "py313", RUST_VERSION: "1.64.0"} - - {VERSION: "3.13", TOXENV: "py313", RUST_VERSION: "beta"} - - {VERSION: "3.13", TOXENV: "py313", RUST_VERSION: "nightly"} + - {VERSION: "3.13", NOXSESSION: "tests", RUST_VERSION: "1.64.0"} + - {VERSION: "3.13", NOXSESSION: "tests", RUST_VERSION: "beta"} + - {VERSION: "3.13", NOXSESSION: "tests", RUST_VERSION: "nightly"} name: "${{ matrix.PYTHON.VERSION }} on linux, Rust ${{ matrix.PYTHON.RUST_VERSION || 'stable' }}" steps: - uses: actions/checkout@v4.2.2 @@ -125,10 +125,10 @@ jobs: with: toolchain: ${{ matrix.PYTHON.RUST_VERSION || 'stable' }} - - run: pip install tox - - run: tox + - run: pip install nox + - run: nox -v env: - TOXENV: ${{ matrix.PYTHON.TOXENV }} + NOXSESSION: ${{ matrix.PYTHON.NOXSESSION }} CARGO_TARGET_DIR: ${{ format('{0}/src/_bcrypt/target/', github.workspace) }} linux-distros: @@ -137,10 +137,10 @@ jobs: strategy: matrix: IMAGE: - - {IMAGE: "alpine", TOXENV: "py312", RUNNER: "ubuntu-latest"} - - {IMAGE: "alpine:aarch64", TOXENV: "py312", RUNNER: [self-hosted, Linux, ARM64]} - - {IMAGE: "ubuntu-rolling:aarch64", TOXENV: "py312", RUNNER: [self-hosted, Linux, ARM64]} - name: "${{ matrix.IMAGE.TOXENV }} on ${{ matrix.IMAGE.IMAGE }}" + - {IMAGE: "alpine", NOXSESSION: "tests", RUNNER: "ubuntu-latest"} + - {IMAGE: "alpine:aarch64", NOXSESSION: "tests", RUNNER: [self-hosted, Linux, ARM64]} + - {IMAGE: "ubuntu-rolling:aarch64", NOXSESSION: "tests", RUNNER: [self-hosted, Linux, ARM64]} + name: "${{ matrix.IMAGE.NOXSESSION }} on ${{ matrix.IMAGE.IMAGE }}" steps: - name: Ridiculous alpine workaround for actions support on arm64 run: | @@ -153,10 +153,10 @@ jobs: - uses: actions/checkout@v4.2.2 with: persist-credentials: false - - run: /venv/bin/pip install tox - - run: '/venv/bin/tox' + - run: /venv/bin/pip install nox + - run: /venv/bin/nox -v env: - TOXENV: ${{ matrix.IMAGE.TOXENV }} + NOXSESSION: ${{ matrix.IMAGE.NOXSESSION }} RUSTUP_HOME: /root/.rustup CARGO_TARGET_DIR: ${{ format('{0}/src/_bcrypt/target/', github.workspace) }} diff --git a/MANIFEST.in b/MANIFEST.in index 9f74e59b..095052c9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,7 +2,7 @@ include LICENSE README.rst include pyproject.toml -include tox.ini .coveragerc +include noxfile.py .coveragerc recursive-include src py.typed *.pyi recursive-include src/_bcrypt Cargo.toml Cargo.lock *.rs diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 00000000..4b1cd65e --- /dev/null +++ b/noxfile.py @@ -0,0 +1,42 @@ +import nox + +nox.options.reuse_existing_virtualenvs = True +nox.options.default_venv_backend = "uv|virtualenv" + + +@nox.session +def tests(session: nox.Session) -> None: + session.install("coverage") + session.install(".[tests]") + + session.run( + "coverage", "run", "-m", "pytest", "--strict-markers", *session.posargs + ) + session.run("coverage", "combine") + session.run("coverage", "report", "-m", "--fail-under", "100") + + +@nox.session +def pep8(session: nox.Session) -> None: + session.install("ruff") + + session.run("ruff", "check", ".") + session.run("ruff", "format", "--check", ".") + + +@nox.session +def mypy(session: nox.Session) -> None: + session.install("mypy") + session.install(".[tests]") + + session.run("mypy", "tests/") + + +@nox.session +def packaging(session: nox.Session) -> None: + session.install("setuptools-rust", "check-manifest", "readme_renderer") + + session.run("check-manifest") + session.run( + "python3", "-m", "readme_renderer", "README.rst", "-o", "/dev/null" + ) diff --git a/pyproject.toml b/pyproject.toml index fda4f637..ab8dda56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,3 +72,6 @@ warn_redundant_casts = true warn_unused_ignores = true warn_unused_configs = true strict_equality = true + +[tool.check-manifest] +ignore = ["tests/reference/*"] diff --git a/tox.ini b/tox.ini deleted file mode 100644 index dfe3e5bb..00000000 --- a/tox.ini +++ /dev/null @@ -1,43 +0,0 @@ -[tox] -isolated_build = True - -[testenv] -extras = - tests -deps = - coverage -passenv = - RUSTUP_HOME -commands = - coverage run -m pytest --strict-markers {posargs} - coverage combine - coverage report -m --fail-under 100 - -[testenv:pep8] -deps = - ruff -commands = - ruff check . - ruff format --check . - -[testenv:mypy] -extras = - tests -deps = - mypy -commands = - mypy tests/ - -[testenv:packaging] -deps = - setuptools-rust - check-manifest - readme_renderer -commands = - check-manifest - python3 -m readme_renderer README.rst -o /dev/null - - -[check-manifest] -ignore = - tests/reference/*