From 811841d1b3de0f70bbab8d59e47fd2a7afc7d068 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Tue, 15 Aug 2023 08:19:09 +0200 Subject: [PATCH] ci: type-check API on all supported versions locally too (#152) --- .github/workflows/ci.yml | 11 +++++++---- pyproject.toml | 3 ++- tox.ini | 28 +++++++++++++--------------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e079620..e6620d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,15 +68,18 @@ jobs: V=py$(echo $V | tr -d .) fi + echo TOX_PYTHON=$V >>$GITHUB_ENV + python -Im pip install tox - python -Im tox run \ - --installpkg dist/*.whl \ - -f $V - run: | python -Im tox run \ --installpkg dist/*.whl \ - -e mypy-api + -f ${{ env.TOX_PYTHON }}-tests + - run: | + python -Im tox run \ + --installpkg dist/*.whl \ + -f ${{ env.TOX_PYTHON }}-mypy if: ${{ !startsWith(matrix.python-version, 'pypy-') }} - name: Upload coverage data diff --git a/pyproject.toml b/pyproject.toml index 875b4b6..33cabf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,8 +43,9 @@ dependencies = [ [project.optional-dependencies] tests = ["hypothesis", "pytest"] +typing = ["mypy"] docs = ["sphinx", "sphinx-notfound-page", "furo", "myst-parser"] -dev = ["argon2-cffi[tests]", "mypy"] +dev = ["argon2-cffi[tests,typing]", "tox>4"] [project.urls] Documentation = "https://argon2-cffi.readthedocs.io/" diff --git a/tox.ini b/tox.ini index 3e27165..1be3dfa 100644 --- a/tox.ini +++ b/tox.ini @@ -2,31 +2,35 @@ min_version = 4 env_list = pre-commit, - mypy-{pkg,api}, - py3{7,8,9,10,11,12} + mypy-pkg, + py3{7,8,9,10,11,12}-{tests,mypy} py311-bindings-main, - pypy3, + pypy3-tests, system-argon2, docs, coverage-report [testenv] -description = Run tests and do NOT measure coverage. +description = Run tests and do NOT measure coverage / type-check. package = wheel wheel_build_env = .pkg -extras = tests +extras = + tests: tests + mypy: typing pass_env = FORCE_COLOR NO_COLOR commands = - pytest {posargs} - python -Im argon2 -n 1 -t 1 -m 8 -p 1 + tests: pytest {posargs} + tests: python -Im argon2 -n 1 -t 1 -m 8 -p 1 + mypy: mypy tests/typing -[testenv:py3{7,11}] +[testenv:py3{7,11}-tests] description = Run tests and measure coverage. -deps = coverage[toml] +deps = + coverage[toml] commands = coverage run -m pytest {posargs} coverage run -m argon2 -n 1 -t 1 -m 8 -p 1 @@ -86,12 +90,6 @@ deps = mypy commands = mypy src -[testenv:mypy-api] -description = Check only API types. -deps = mypy -commands = mypy tests/typing - - [testenv:docs] description = Build docs and run doctests. # Keep base_python in-sync with .readthedocs.yaml and ci.yml/docs.