Skip to content

Commit 91e0e61

Browse files
authored
Ensure we test coverage uploading (#246)
1 parent ee510b9 commit 91e0e61

14 files changed

+197
-33
lines changed

.config/requirements-docs.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
argparse-manpage
2+
mkdocs-ansible>=24.12.0 # do not use lock extra because it would break dependabot updates
3+
mkdocs-exclude

.config/requirements-test.in

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
coverage>=7.6.9
2+
# pytest-cov
3+
pytest-instafail
4+
pytest-plus
5+
pytest>=8

.config/requirements.in

Whitespace-only changes.

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
uses: ./.github/workflows/tox.yml
1414
with:
1515
default_python: "3.10"
16-
jobs_producing_coverage: 0
16+
jobs_producing_coverage: 6
1717
max_python: "3.13"
1818
min_python: "3.10"
1919
run_post: echo 'Running post'

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,4 @@ dmypy.json
132132
.vault
133133

134134
_readthedocs/
135+
src/team_devtools/_version.py

.readthedocs.yml

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ python:
1616
install:
1717
- method: pip
1818
path: tox
19+
- method: pip
20+
path: .
21+
extra_requirements:
22+
- docs
1923
submodules:
2024
include: all
2125
recursive: true

codecov.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
comment: false
3+
coverage:
4+
status:
5+
patch: true
6+
project:
7+
default:
8+
threshold: 0.5%

pyproject.toml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = [
4+
"setuptools >= 65.3.0", # required by pyproject+setuptools_scm integration and editable installs
5+
"setuptools_scm[toml] >= 7.0.5" # required for "no-local-version" scheme
6+
]
7+
8+
[project]
9+
description = "..."
10+
dynamic = ["version", "dependencies", "optional-dependencies"]
11+
name = "team-devtools"
12+
readme = "README.md"
13+
# https://peps.python.org/pep-0621/#readme
14+
requires-python = ">=3.10"
15+
# Keep this default because xml/report do not know to use load it from config file:
16+
# data_file = ".coverage"
17+
[tool.coverage.paths]
18+
source = ["src", "test", ".tox/*/site-packages"]
19+
20+
[tool.coverage.report]
21+
exclude_also = ["pragma: no cover", "if TYPE_CHECKING:"]
22+
# Increase it just so it would pass on any single-python run
23+
fail_under = 100
24+
omit = ["test/*"]
25+
show_missing = true
26+
skip_covered = true
27+
skip_empty = true
28+
29+
[tool.coverage.run]
30+
concurrency = ["multiprocessing", "thread"]
31+
# Do not use branch until bug is fixes:
32+
# https://github.com/nedbat/coveragepy/issues/605
33+
# branch = true
34+
parallel = true
35+
source = ["src"]
36+
[tool.pytest.ini_options]
37+
addopts = "-p no:pytest_cov --durations=10 --failed-first"
38+
norecursedirs = [
39+
"*.egg",
40+
".cache",
41+
".config",
42+
".eggs",
43+
".git",
44+
".github",
45+
".mypy_cache",
46+
".projects",
47+
".eggs",
48+
".tox",
49+
"__pycache__",
50+
"build",
51+
"collections",
52+
"dist",
53+
"docs",
54+
"site",
55+
"src/*.egg-info"
56+
]
57+
58+
[tool.setuptools.dynamic]
59+
dependencies = {file = [".config/requirements.in"]}
60+
optional-dependencies.docs = {file = [".config/requirements-docs.in"]}
61+
optional-dependencies.test = {file = [".config/requirements-test.in"]}
62+
[tool.setuptools_scm]
63+
# To prevent accidental pick of mobile version tags such 'v6'
64+
git_describe_command = [
65+
"git",
66+
"describe",
67+
"--dirty",
68+
"--long",
69+
"--tags",
70+
"--match",
71+
"v*.*"
72+
]
73+
local_scheme = "no-local-version"
74+
tag_regex = "^(?P<prefix>v)?(?P<version>[0-9.]+)(?P<suffix>.*)?$"
75+
write_to = "src/team_devtools/_version.py"
76+
77+
[tool.tomlsort]
78+
in_place = true
79+
sort_inline_tables = true
80+
sort_table_keys = true
81+
82+
[tool.uv.pip]
83+
annotation-style = "line"
84+
custom-compile-command = "tox run deps"
85+
no-emit-package = ["ansible-core", "pip", "resolvelib", "typing_extensions", "uv"]

readthedocs.yml

-18
This file was deleted.

requirements.in

-5
This file was deleted.

src/team_devtools/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
try:
2+
from ._version import __version__
3+
except ImportError: # pragma: no cover
4+
__version__ = "unknown"
5+
6+
__all__ = ("__version__",)

test/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Use ansiblelint.testing instead for reusable tests."""

test/test_one.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Test module for the package."""
2+
3+
4+
def test_placeholder():
5+
"""Placeholder test."""
6+
from team_devtools import __version__

tox.ini

+77-9
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,75 @@
11
[tox]
2-
minversion = 4.0
2+
minversion = 4.6.3
33
envlist =
44
lint
5+
pkg
6+
py
57
docs
68
ubi8
79
ubi9
810
isolated_build = True
911
requires =
10-
tox>=4.21.2
11-
tox-uv>=1.15.0
12+
tox>=4.21.2
13+
tox-extra >= 2.0.1
14+
tox-uv >= 1.16.0
15+
setuptools >= 65.3.0 # editable installs
1216

1317
[testenv]
18+
extras =
19+
test
20+
commands_pre =
21+
sh -c "rm -f {envdir}/.coverage.* 2>/dev/null || true"
22+
# safety measure to assure we do not accidentally run tests with broken dependencies
23+
{envpython} -m pip check
1424
commands =
15-
skip_install = true
25+
coverage run -m pytest {posargs:\
26+
-ra \
27+
--showlocals \
28+
--doctest-modules \
29+
--durations=10 \
30+
}
31+
{py,py310,py311,py312,py313}: sh -xc "coverage combine -a -q --data-file={envdir}/.coverage {toxworkdir}/*/.coverage.* && coverage report --data-file={envdir}/.coverage && coverage xml --data-file={envdir}/.coverage -o {envdir}/coverage.xml"
32+
editable = true
33+
pass_env =
34+
CURL_CA_BUNDLE # https proxies, https://github.com/tox-dev/tox/issues/1437
35+
FORCE_COLOR
36+
HOME
37+
LANG
38+
LC_*
39+
NO_COLOR
40+
PYTEST_* # allows developer to define their own preferences
41+
PYTEST_REQPASS # needed for CI
42+
PYTHON* # PYTHONPYCACHEPREFIX, PYTHONIOENCODING, PYTHONBREAKPOINT,...
43+
PY_COLORS
44+
RTD_TOKEN
45+
REQUESTS_CA_BUNDLE # https proxies
46+
SETUPTOOLS_SCM_DEBUG
47+
SSL_CERT_FILE # https proxies
48+
SSH_AUTH_SOCK # may be needed by git
49+
UV_*
50+
# recreate = True
51+
setenv =
52+
COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}}
53+
COVERAGE_PROCESS_START={toxinidir}/pyproject.toml
54+
skip_install = false
1655
usedevelop = false
1756
changedir = {toxinidir}
57+
allowlist_externals =
58+
sh
59+
uv_seed = true
1860

1961
[testenv:docs]
2062
description = Build docs
21-
deps =
22-
-r requirements.in
23-
ansible-core
63+
extras = docs
2464
passenv =
2565
*
66+
setenv =
67+
# see https://github.com/tox-dev/tox/issues/2092#issuecomment-2538729079
68+
# see https://github.com/Kozea/CairoSVG/issues/392#issuecomment-2538707712
69+
DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib:{env:DYLD_FALLBACK_LIBRARY_PATH}
2670
commands =
27-
; ansible-playbook -i localhost, playbooks/sync.yml
2871
{envpython} -m mkdocs {posargs:build --strict --site-dir=_readthedocs/html/}
29-
skip_install = true
72+
skip_install = false
3073
usedevelop = false
3174

3275
[testenv:lint]
@@ -50,3 +93,28 @@ commands =
5093
podman run -it adt-{envname} adt --version
5194
allowlist_externals =
5295
podman
96+
[testenv:pkg]
97+
description =
98+
Build package, verify metadata, install package and assert behavior when ansible is missing.
99+
deps =
100+
build >= 0.9.0
101+
twine >= 4.0.1
102+
pip
103+
pipx
104+
skip_install = true
105+
# Ref: https://twitter.com/di_codes/status/1044358639081975813
106+
commands_pre =
107+
commands =
108+
# build wheel and sdist using PEP-517
109+
{envpython} -c 'import os.path, shutil, sys; \
110+
dist_dir = os.path.join("{toxinidir}", "dist"); \
111+
os.path.isdir(dist_dir) or sys.exit(0); \
112+
print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \
113+
shutil.rmtree(dist_dir)'
114+
{envpython} -m build --outdir {toxinidir}/dist/ {toxinidir}
115+
# Validate metadata using twine
116+
python3 -m twine check --strict {toxinidir}/dist/*
117+
# Install the wheel
118+
sh -c 'python3 -m pip install "team-devtools @ file://$(echo {toxinidir}/dist/*.whl)"'
119+
# Uninstall it
120+
python3 -m pip uninstall -y team-devtools

0 commit comments

Comments
 (0)