Skip to content

Commit 90a926a

Browse files
committed
🧪📦 Add packaging envs to tox
They include cleaning the dist dir, producing the dists and verifying their metadata.
1 parent c21a890 commit 90a926a

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ requires = [
66
build-backend = 'hatchling.build'
77

88
[dependency-groups]
9+
building = [
10+
'build',
11+
]
912
linting = [
1013
'pre-commit',
1114
]
@@ -16,6 +19,9 @@ testing = [
1619
'pytest-mock', # provides a `mocker` fixture
1720
'pytest-xdist', # paralellizes tests through subprocesses
1821
]
22+
upstreaming = [
23+
'twine',
24+
]
1925

2026
[project]
2127
name = 'pre-commit-terraform'

tox.ini

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,64 @@ set_env =
102102
wheel_build_env = .pkg
103103

104104

105+
[testenv:cleanup-dists]
106+
description =
107+
Wipe the the dist{/} folder
108+
dependency_groups =
109+
commands_pre =
110+
commands =
111+
{envpython} \
112+
{[python-cli-options]byte-errors} \
113+
{[python-cli-options]max-isolation} \
114+
{[python-cli-options]warnings-to-errors} \
115+
-c \
116+
'import os, shutil, sys; \
117+
dists_dir = "{toxinidir}{/}dist{/}"; \
118+
shutil.rmtree(dists_dir, ignore_errors=True); \
119+
sys.exit(os.path.exists(dists_dir))'
120+
commands_post =
121+
package = skip
122+
123+
124+
[testenv:build-dists]
125+
description =
126+
Build dists with {basepython} and put them into the dist{/} folder
127+
dependency_groups =
128+
building
129+
depends =
130+
cleanup-dists
131+
commands =
132+
{envpython} \
133+
{[python-cli-options]byte-errors} \
134+
{[python-cli-options]max-isolation} \
135+
{[python-cli-options]warnings-to-errors} \
136+
-m build \
137+
{posargs:}
138+
commands_post =
139+
package = skip
140+
141+
142+
[testenv:metadata-validation]
143+
description =
144+
Verify that dists under the `dist{/}` dir
145+
have valid metadata
146+
dependency_groups =
147+
upstreaming
148+
depends =
149+
build-dists
150+
commands =
151+
{envpython} \
152+
{[python-cli-options]byte-errors} \
153+
{[python-cli-options]max-isolation} \
154+
{[python-cli-options]warnings-to-errors} \
155+
-m twine \
156+
check \
157+
--strict \
158+
dist{/}*
159+
commands_post =
160+
package = skip
161+
162+
105163
[testenv:pre-commit]
106164
description =
107165
Run the quality checks under {basepython}; run as

0 commit comments

Comments
 (0)