Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: update tox config to latest starbase #4131

Merged
merged 5 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 0 additions & 137 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,140 +40,3 @@ ignore = E203,E501
# D213 Multi-line docstring summary should start at the second line (reason: pep257 default)
ignore = D107, D203, D213
ignore_decorators = overrides

[tox:tox]
min_version = 4.0
env_list =
# Parametrized environments.
# First parameter allows us to choose Python 3.8 or 3.10.
# Second parameter chooses how to define the environment:
# withreq: using requirements-devel.txt
# noreq: Without either requirements file (but including dev requirements)
# Third parameter selects the current unit tests (unit) or the legacy unit tests (legacy)
py{38,310}-{withreq,noreq}-{unit,legacy}
skip_missing_interpreters = true
labels =
# Minimal testing environments. run with `tox run-parallel -m test`
test = py38-withreq-{unit,legacy}
# Test in Python 3.10 from an empty environment.
future-test = py310-noreq-{unit,legacy}
# Environments to run in CI
ci = py{38,310}-withreq-{unit,legacy},py{38,310}-noreq-unit
# Just run the regular unit tests, not the legacy ones
unit = py{38,310}-{withreq,noreq}-unit
# Legacy unit tests only
legacy = py{38,310}-{withreq,noreq}-legacy

[testenv]
deps =
withreq,pylint,mypy,pyright: -r{tox_root}/requirements-devel.txt
noreq: PyNaCl>=1.5.0
noreq,codespell: python-apt@git+https://salsa.debian.org/apt-team/python-apt.git@2.0.0
extras =
noreq: dev
package = wheel
set_env =
SNAPCRAFT_IGNORE_YAML_BINDINGS = 1
COVERAGE_FILE = .coverage_{env_name}

[testenv:py{38,310}-{withreq,noreq}-unit]
description = Run the unit tests
commands =
pytest {tty:--color=yes} --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml tests/unit {posargs}

[testenv:py{38,310}-{withreq,noreq}-legacy]
description = Run the legacy unit tests
commands =
pytest {tty:--color=yes} --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml tests/legacy/unit/ {posargs}

[testenv:format-black]
description = Autoformat with black
labels = fix
deps = black
skip_install = true
# Note: this does not include `snapcraft_legacy` as it contains several files that need reformatting.
commands = black setup.py snapcraft tests

[testenv:format-ruff]
base = ruff
description = Autoformat with ruff
labels = fix
commands =
ruff --fix setup.py snapcraft tests tools
ruff --fix --config snapcraft_legacy/ruff.toml snapcraft_legacy tests/legacy

[testenv:pylint]
description = Lint with pylint
labels = lint
# This runs all commands even if the first fails.
# Not to be confused with ignore_outcome, which turns errors into warnings.
ignore_errors = true
commands =
pylint -j 0 snapcraft
pylint -j 0 tests --disable=invalid-name,missing-module-docstring,missing-function-docstring,duplicate-code,protected-access,unspecified-encoding,too-many-public-methods,too-many-arguments,too-many-lines,redefined-outer-name

[testenv:shellcheck]
description = Check spelling with shellcheck
labels = lint
skip_install = true
allowlist_externals = bash, git
commands = bash -c "git ls-files | file --mime-type -Nnf- | grep shellscript | cut -f1 -d: | xargs shellcheck"

[testenv:spread-shellcheck]
description = Run shellcheck on spread's test.yaml files using spread-shellcheck.py
labels = lint
deps = pyyaml
skip_install = true
commands = python3 tools/spread-shellcheck.py spread.yaml tests/spread/

[testenv:mypy]
description = Run mypy
labels = type, lint
skip_install = true
commands = mypy --install-types --non-interactive .

[testenv:pyright]
description = run PyRight
labels = type, lint
allowlist_externals = pyright
commands = pyright snapcraft tests

[testenv:black]
description = run black in checking mode
skip_install = true
labels = lint
deps = black
commands = black --check --diff setup.py snapcraft tests

[testenv:codespell]
description = Check spelling with codespell
skip_install = true
labels = lint
deps = codespell
commands = codespell

[testenv:ruff]
description = Lint with ruff
skip_install = true
labels = lint
deps = ruff==0.0.220
# This runs all commands even if the first fails.
# Not to be confused with ignore_outcome, which turns errors into warnings.
ignore_errors = true
commands =
ruff --config snapcraft_legacy/ruff.toml snapcraft_legacy tests/legacy
ruff setup.py snapcraft tests tools

[testenv:isort]
description = Check import order with isort
skip_install = true
labels = lint
deps = isort
commands = isort --check .

[testenv:docstyle]
description = Check documentation style with pydocstyle
skip_install = true
labels = lint
deps = pydocstyle
commands = pydocstyle snapcraft
13 changes: 7 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ def recursive_data_files(directory, install_directory):
scripts = []

dev_requires = [
"black",
"codespell",
"black==23.1.0",
lengau marked this conversation as resolved.
Show resolved Hide resolved
"codespell[toml]==2.2.4",
"coverage[toml]",
"pyflakes",
"fixtures",
"isort",
"isort==5.11.4",
"mccabe",
"mypy",
"testscenarios",
"pexpect",
"pip",
"pycodestyle",
"pydocstyle",
"pydocstyle==6.2.3",
"pyftpdlib",
"pylint",
"pylint-fixme-info",
Expand All @@ -83,11 +83,12 @@ def recursive_data_files(directory, install_directory):
"pytest-mock",
"pytest-subprocess",
"ruff==0.0.220",
"tox>=4.0",
"tox>=4.5",
"types-PyYAML",
"types-requests",
"types-setuptools",
"types-tabulate",
"yamllint==1.29.0",
]

if sys.platform == "win32":
Expand Down Expand Up @@ -151,7 +152,7 @@ def recursive_data_files(directory, install_directory):
if ubuntu:
install_requires += [
"catkin-pkg",
"python-apt",
"python-apt@https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/python-apt/2.0.0ubuntu0.20.04.6/python-apt_2.0.0ubuntu0.20.04.6.tar.xz",
"python-debian",
]

Expand Down
21 changes: 3 additions & 18 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ env_list = # Environments to run when called with no parameters.
lint-{black,ruff,isort,mypy,pylint,pyright,shellcheck,codespell,yaml}
test-py38
test-legacy-py38
minversion = 3.8
minversion = 4.5
# Tox will use these requirements to bootstrap a venv if necessary.
# tox-igore-env-name-mismatch allows us to have one virtualenv for all linting.
# By setting requirements here, we make this INI file compatible with older
# versions of tox. Tox >= 3.8 will automatically provision the version provided
# inside of a virtual environment, so users of Ubuntu >= focal can simply
# install tox from apt. Older than that, the user gets an upgrade warning.
requires =
# renovate: datasource=pypi
tox==4.4.6
# renovate: datasource=pypi
tox-ignore-env-name-mismatch==0.2.0.post2
# Allow tox to access the user's $TMPDIR environment variable if set.
Expand Down Expand Up @@ -77,21 +75,8 @@ commands =
pytest {tty:--color=yes} --junit-xml=results/legacy-test-results-{env_name}.xml tests/legacy {posargs}

[lint] # Standard linting configuration
skip_install = true
deps =
# renovate: datasource=pypi
black==23.1.0
# renovate: datasource=pypi
ruff==0.0.220
# renovate: datasource=pypi
codespell[tomli]==2.2.4
# renovate: datasource=pypi
yamllint==1.29.0
# renovate: datasource=pypi
isort==5.11.4
# renovate: datasource=pypi
pydocstyle==6.2.3
python-apt@http://archive.ubuntu.com/ubuntu/pool/main/p/python-apt/python-apt_2.4.0ubuntu1.tar.xz
package = editable
extras = dev
env_dir = {work_dir}/linting
runner = ignore_env_name_mismatch

Expand Down