Skip to content

Commit 0d4dbca

Browse files
committed
Ensure we test coverage uploading
1 parent 0e78cd6 commit 0d4dbca

File tree

11 files changed

+201
-9
lines changed

11 files changed

+201
-9
lines changed
File renamed without changes.

.config/requirements-test.in

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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'

codecov.yml

Lines changed: 8 additions & 0 deletions
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

Lines changed: 85 additions & 0 deletions
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"]

src/team_devtools/__init__.py

Lines changed: 6 additions & 0 deletions
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__",)

src/team_devtools/_version.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# file generated by setuptools_scm
2+
# don't change, don't track in version control
3+
TYPE_CHECKING = False
4+
if TYPE_CHECKING:
5+
from typing import Tuple, Union
6+
VERSION_TUPLE = Tuple[Union[int, str], ...]
7+
else:
8+
VERSION_TUPLE = object
9+
10+
version: str
11+
__version__: str
12+
__version_tuple__: VERSION_TUPLE
13+
version_tuple: VERSION_TUPLE
14+
15+
__version__ = version = '22.5.1.dev19'
16+
__version_tuple__ = version_tuple = (22, 5, 1, 'dev19')

test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Use ansiblelint.testing instead for reusable tests."""

test/test_one.py

Lines changed: 6 additions & 0 deletions
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

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,72 @@
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
*
2666
commands =
2767
; ansible-playbook -i localhost, playbooks/sync.yml
2868
{envpython} -m mkdocs {posargs:build --strict --site-dir=_readthedocs/html/}
29-
skip_install = true
69+
skip_install = false
3070
usedevelop = false
3171

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

0 commit comments

Comments
 (0)