Switch to nox (#954)

This commit is contained in:
Alex Gaynor 2025-01-17 15:50:58 -05:00 committed by GitHub
parent df983f9c98
commit 765a3851de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 82 additions and 80 deletions

View File

@ -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) }}

View File

@ -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

42
noxfile.py Normal file
View File

@ -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"
)

View File

@ -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/*"]

43
tox.ini
View File

@ -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/*