-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtox.ini
More file actions
415 lines (335 loc) · 11.3 KB
/
tox.ini
File metadata and controls
415 lines (335 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# =============================================================================
# Tox Configuration
# https://tox.wiki/en/stable/
# =============================================================================
#
# This file is portable - copy to other repos without modification.
#
# Tox automates testing across multiple Python versions and Django versions,
# runs linters, type checkers, formatters, and security scanners in isolated
# virtual environments.
#
# Usage:
# tox Run all default environments (envlist)
# tox -e py312 Run single environment
# tox -e lint,typecheck Run multiple specific environments
# tox -p auto Run environments in parallel
# tox -l List all available environments
# tox --recreate Force recreate virtual environments
#
# =============================================================================
# =============================================================================
# Global Settings
# =============================================================================
[tox]
# Default environments to run (order matters for CI output)
envlist =
# Python 3.12 with Django versions
py312-django50
py312-django51
py312-django52
py312-django60
# Python 3.13 with Django versions
py313-django50
py313-django51
py313-django52
py313-django60
# Python 3.14 with Django versions
py314-django50
py314-django51
py314-django52
py314-django60
# Python 3.15 with Django versions
py315-django50
py315-django51
py315-django52
py315-django60
# Code quality checks
lint
typecheck
security
# Use PEP 517/518 build system (pyproject.toml)
isolated_build = true
# Don't fail if Python version not installed (useful for local dev)
skip_missing_interpreters = true
# =============================================================================
# Test Environment (Default)
# =============================================================================
#
# Runs pytest with coverage against the swing.wellknown package.
# Matrix: Python versions × Django versions
#
# Examples:
# tox -e py312-django51 # Python 3.12 + Django 5.1
# tox -e py313-django60 # Python 3.13 + Django 6.0
# tox -- -k "test_model" # Pass args to pytest
#
# =============================================================================
[testenv]
description = Run tests with pytest
# Install Django version based on factor (e.g., django51 → Django>=5.1,<5.2)
deps =
django50: Django>=5.0,<5.1
django51: Django>=5.1,<5.2
django52: Django>=5.2,<5.3
django60: Django>=6.0,<6.1
pytest>=8.0
pytest-django>=4.5
pytest-cov>=4.0
coverage[toml]>=7.0
# Environment variables for Django
setenv =
DJANGO_SETTINGS_MODULE = tst.settings
PYTHONPATH = {toxinidir}/src:{toxinidir}
# Run pytest with coverage; {posargs} allows extra args via: tox -- -k "test_"
commands =
pytest tst/ --cov=swing.wellknown --cov-branch --cov-fail-under=60 {posargs}
# Pass through environment variables (needed for CI and some tools)
passenv =
HOME
USER
CI
GITHUB_*
# =============================================================================
# Python Linting
# =============================================================================
#
# Static analysis for Python code quality and style.
#
# Run: tox -e lint
#
# =============================================================================
[testenv:lint]
description = Run linters (flake8, pylint)
# Don't install the package itself
skip_install = true
deps =
flake8>=7.0
pylint>=3.0
pylint-django>=2.5
commands =
# flake8: PEP 8 style + common errors
flake8 src/
# pylint: deeper analysis (errors only for speed)
pylint src/ --errors-only
# =============================================================================
# Type Checking
# =============================================================================
#
# Static type analysis with mypy for catching type errors.
#
# Run: tox -e typecheck
#
# =============================================================================
[testenv:typecheck]
description = Run type checker (mypy)
deps =
mypy>=1.8
django-stubs>=4.2
types-requests
commands =
mypy src/
# =============================================================================
# Format Checking
# =============================================================================
#
# Verify code formatting without making changes.
# Use format-fix to auto-fix issues.
#
# Run: tox -e format
#
# =============================================================================
[testenv:format]
description = Check code formatting
skip_install = true
deps =
black>=24.0
isort>=5.13
add-trailing-comma>=4.0
docformatter>=1.7
commands =
# Check black formatting
black --check --config .black.toml src/ tst/
# Check import sorting
isort --check-only src/ tst/
# Check docstring formatting
docformatter --check --diff --recursive src/ tst/
# =============================================================================
# Auto-Format Code
# =============================================================================
#
# Automatically fix formatting issues in-place.
# Order matters: trailing commas → docstrings → imports → black
#
# Run: tox -e format-fix
#
# =============================================================================
[testenv:format-fix]
description = Auto-format code with black, isort, docformatter, and add-trailing-comma
skip_install = true
# Allow bash for find command
allowlist_externals = bash
deps =
black>=24.0
isort>=5.13
add-trailing-comma>=4.0
docformatter>=1.7
commands =
# 1. Add trailing commas (prevents diff noise)
bash -c "find src tst -name '*.py' -exec add-trailing-comma --exit-zero-even-if-changed {} +"
# 2. Format docstrings (Google style, 79 chars)
docformatter --in-place --recursive --pre-summary-newline --close-quotes-on-newline --make-summary-multi-line --wrap-summaries 79 --wrap-descriptions 79 src/ tst/
# 3. Sort imports
isort src/ tst/
# 4. Format code (must be last - definitive style)
black --config .black.toml src/ tst/
# =============================================================================
# Security Scanning
# =============================================================================
#
# Scan for common security issues with bandit.
#
# Run: tox -e security
#
# =============================================================================
[testenv:security]
description = Run security checks with bandit
skip_install = true
deps =
bandit[toml]>=1.7
commands =
bandit -r src/ -c .bandit.yaml
# =============================================================================
# JavaScript/TypeScript Linting
# =============================================================================
#
# Lint frontend code with ESLint (requires Node.js).
#
# Run: tox -e lint-js
#
# =============================================================================
[testenv:lint-js]
description = Lint JavaScript/TypeScript with ESLint
skip_install = true
# Allow npx command (Node.js)
allowlist_externals = npx
commands =
npx eslint src/ --ext .js,.ts,.jsx,.tsx
# =============================================================================
# CSS/SCSS Linting
# =============================================================================
#
# Lint stylesheets with Stylelint (requires Node.js).
#
# Run: tox -e lint-css
#
# =============================================================================
[testenv:lint-css]
description = Lint CSS/SCSS with Stylelint
skip_install = true
allowlist_externals = npx
commands =
npx stylelint "src/**/*.{css,scss}"
# =============================================================================
# HTML/Template Linting
# =============================================================================
#
# Lint Django/Jinja templates with djLint.
#
# Run: tox -e lint-html
#
# =============================================================================
[testenv:lint-html]
description = Lint HTML/Jinja templates with djLint
skip_install = true
deps =
djlint>=1.36
commands =
djlint src/ --lint
# =============================================================================
# JavaScript/CSS Formatting
# =============================================================================
#
# Format frontend code with Prettier (requires Node.js).
#
# Run: tox -e format-js
#
# =============================================================================
[testenv:format-js]
description = Format JavaScript/TypeScript/CSS/SCSS with Prettier
skip_install = true
allowlist_externals = npx
commands =
npx prettier --write "src/**/*.{js,ts,jsx,tsx,css,scss,json}"
# =============================================================================
# HTML/Template Formatting
# =============================================================================
#
# Format Django/Jinja templates with djLint.
#
# Run: tox -e format-html
#
# =============================================================================
[testenv:format-html]
description = Format HTML/Jinja templates with djLint
skip_install = true
deps =
djlint>=1.36
commands =
djlint src/ --reformat
# =============================================================================
# Documentation Build
# =============================================================================
#
# Build MkDocs documentation with strict mode (fail on warnings).
#
# Run: tox -e docs
#
# =============================================================================
[testenv:docs]
description = Build documentation with mkdocs
deps =
mkdocs>=1.5
mkdocs-material>=9.0
commands =
mkdocs build --strict
# =============================================================================
# Cleanup
# =============================================================================
#
# Remove temporary files, caches, and build artifacts.
#
# Run: tox -e clean
#
# =============================================================================
[testenv:clean]
description = Clean up temporary files and caches
skip_install = true
commands =
# Remove all __pycache__ directories
python -c "import shutil; import pathlib; [shutil.rmtree(p, ignore_errors=True) for p in pathlib.Path('.').rglob('__pycache__')]"
# Remove tool caches and build outputs
python -c "import shutil; [shutil.rmtree(p, ignore_errors=True) for p in ['.pytest_cache', '.mypy_cache', '.ruff_cache', 'htmlcov', 'site', '.coverage']]"
# =============================================================================
# Coverage Report
# =============================================================================
#
# Generate detailed coverage report (HTML + terminal).
# Useful for local development to inspect uncovered lines.
#
# Run: tox -e coverage
#
# =============================================================================
[testenv:coverage]
description = Generate detailed coverage report (HTML + terminal)
deps =
Django>=5.1,<5.2
pytest>=8.0
pytest-django>=4.5
pytest-cov>=4.0
coverage[toml]>=7.0
setenv =
DJANGO_SETTINGS_MODULE = tst.settings
PYTHONPATH = {toxinidir}/src:{toxinidir}
commands =
pytest tst/ --cov=swing.wellknown --cov-report=html --cov-report=term-missing