Skip to content

Commit

Permalink
Streamline tox.ini / ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Feb 7, 2023
1 parent 1f01557 commit cce890c
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 85 deletions.
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
exclude = src/argon2/_ffi.py
ignore =
# Ambiguous variable names
# Ignored, since there is an enum value "I" for the algorithm type Argon2I
E741
# Not an actual PEP8 violation
W503
# Black vs flake8 conflict
E203

# vim: ft=dosini
74 changes: 57 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ env:
SETUPTOOLS_SCM_PRETEND_VERSION: "1.0" # avoid warnings about shallow checkout
PIP_DISABLE_PIP_VERSION_CHECK: 1
PIP_NO_PYTHON_VERSION_WARNING: 1
PYTHON_LATEST: "3.10"
# Keep in sync with .pre-commit-config.yaml/default_language_version/python.
PYTHON_LATEST: "3.11"

permissions:
contents: read

jobs:
tests:
name: tox on ${{ matrix.python-version }}
name: Tests on ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -50,9 +51,25 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install --upgrade wheel tox tox-gh-actions
- run: python -Im pip install --upgrade wheel tox

- run: python -m tox
- name: Determine Python version for tox
run: |
V=${{ matrix.python-version }}
if [[ "$V" = ~* ]]; then
# Extract version from a '~3.XX.0-0' specifier.
V=${V:1:4}
fi
if [[ "$V" = pypy-* ]]; then
V=pypy3
else
V=py$(echo $V | tr -d .)
fi
echo TOX_PYTHON=$V >>$GITHUB_ENV
- run: python -Im tox run -f ${{ env.TOX_PYTHON }}

- name: Upload coverage data
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -82,17 +99,17 @@ jobs:
# Use latest Python, so it understands all syntax.
python-version: ${{env.PYTHON_LATEST}}

- run: python -m pip install --upgrade coverage[toml]
- run: python -Im pip install --upgrade coverage[toml]

- uses: actions/download-artifact@v3
with:
name: coverage-data

- name: Combine coverage & fail if it's <100%.
run: |
python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=100
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
python -Im coverage report --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -128,10 +145,32 @@ jobs:
run: |
sudo apt-get install libargon2-0 libargon2-0-dev
python -VV
python -m site
python -m pip install --upgrade wheel tox
python -Im site
python -Im pip install --upgrade wheel tox
- run: python -m tox -e system-argon2
- run: python -Im tox run -e system-argon2

mypy:
name: Mypy on ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- run: python -Im pip install --upgrade wheel tox
- run: python -Im tox run -e mypy

docs:
name: Build docs & run doctests
Expand All @@ -151,9 +190,9 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: python -Im pip install --upgrade wheel tox

- run: python -m pip install --upgrade wheel tox
- run: tox -e docs
- run: tox run -e docs

package:
name: Build & verify package
Expand All @@ -170,10 +209,10 @@ jobs:
files.pythonhosted.org:443
github.com:443
pypi.org:443
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: hynek/build-and-inspect-python-package@v1

install-dev:
Expand All @@ -196,9 +235,10 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{env.PYTHON_LATEST}}
- run: python -m pip install -e .[dev]
- run: python -m argon2 -n 1 -t 1 -m 8 -p 1
python-version: ${{ env.PYTHON_LATEST }}
- run: python -Im pip install -e .[dev]

- run: python -Im argon2 -n 1 -t 1 -m 8 -p 1

# Ensure everything required is passing for branch protection.
required-checks-pass:
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ ci:
autoupdate_schedule: monthly

default_language_version:
python: python3.10
# Keep in sync with ci.yml/PYTHON_LATEST
python: python3.11

repos:
- repo: https://github.com/psf/black
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ branch = true
source = ["argon2"]

[tool.coverage.paths]
source = ["src", ".tox/py*/**/site-packages"]
source = ["src", ".tox/**/site-packages"]

[tool.coverage.report]
show_missing = true
Expand Down
98 changes: 32 additions & 66 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
[flake8]
exclude = src/argon2/_ffi.py
ignore =
# Ambiguous variable names
# Ignored, since there is an enum value "I" for the algorithm type Argon2I
E741
# Not an actual PEP8 violation
W503
# Black vs flake8 conflict
E203


# We don't run pre-commit in CI, because we use pre-commit.ci.
[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39, mypy
3.10: py310, bindings-main
3.11: py311
pypy-3: pypy3


[tox]
envlist = pre-commit,mypy,py37,py38,py39,py310,py311,pypy3,system-argon2,bindings-main,docs,pypi-description,coverage-report
isolated_build = true
min_version = 4
env_list =
pre-commit,
mypy,
py37,
py38,
py39,
py310,
py311{,-bindings-main},
pypy3,
system-argon2,
docs,
coverage-report


[testenv:docs]
description = Build docs and run doctests.
# Keep basepython in-sync with .readthedocs.yml and ci.yml/docs.
basepython = python3.10
# Keep base_python in-sync with .readthedocs.yaml and ci.yml/docs.
base_python = python3.10
extras = docs
commands =
python -m doctest README.md
python -Im doctest README.md
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
sphinx-build -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html

Expand All @@ -54,39 +42,28 @@ commands = mypy src typing_examples.py
description = Run tests and do NOT measure coverage.
extras = tests
commands =
python -m pytest {posargs}
python -m argon2 -n 1 -t 1 -m 8 -p 1
python -Im pytest {posargs}
python -Im argon2 -n 1 -t 1 -m 8 -p 1


[testenv:py37]
[testenv:py3{7,11}]
description = Run tests and measure coverage.
deps = coverage[toml]
commands =
coverage run -m pytest {posargs}
coverage run -m argon2 -n 1 -t 1 -m 8 -p 1
coverage run -m argon2 --profile CHEAPEST


[testenv:py310]
description = Run tests and measure coverage.
deps = coverage[toml]
commands =
coverage run -m pytest {posargs}
coverage run -m argon2 -n 1 -t 1 -m 8 -p 1
coverage run -m argon2 --profile CHEAPEST
python -Im coverage run -m pytest {posargs}
python -Im coverage run -m argon2 -n 1 -t 1 -m 8 -p 1
python -Im coverage run -m argon2 --profile CHEAPEST


[testenv:coverage-report]
description = Report coverage over all test runs.
skip_install = true
depends =
py37
py310
basepython = python3.10
depends = py3{7,11}
deps = coverage[toml]
parallel_show_output = true
commands =
coverage combine
coverage report
python -Im coverage combine
python -Im coverage report


[testenv:system-argon2]
Expand All @@ -95,26 +72,15 @@ setenv = ARGON2_CFFI_USE_SYSTEM=1
install_command =
pip install {opts} --no-binary=argon2-cffi-bindings {packages}
commands =
python -m pytest {posargs}
python -m argon2 -n 1 -t 1 -m 8 -p 1
python -Im pytest {posargs}
python -Im argon2 -n 1 -t 1 -m 8 -p 1


[testenv:bindings-main]
[testenv:py311-bindings-main]
description = Run tests against the current main branch of argon2-cffi-bindings
install_command = pip install {opts} --no-deps {packages}
extras =
commands =
pip install hypothesis pytest git+https://github.com/hynek/argon2-cffi-bindings
python -m pytest {posargs}
python -m argon2 -n 1 -t 1 -m 8 -p 1


[testenv:pypi-description]
description = Ensure README renders on PyPI.
skip_install = true
deps =
twine
pip >= 18.0.0
commands =
pip wheel -w {envtmpdir}/build --no-deps .
twine check {envtmpdir}/build/*
pip install -I hypothesis pytest git+https://github.com/hynek/argon2-cffi-bindings
python -Im pytest {posargs}
python -Im argon2 -n 1 -t 1 -m 8 -p 1

0 comments on commit cce890c

Please sign in to comment.