-
Notifications
You must be signed in to change notification settings - Fork 10
/
tox.ini
131 lines (113 loc) · 3.66 KB
/
tox.ini
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
# Can be run through "tox.sh" for convenience
[tox]
# Required for `tox -p auto` to work; here's the commit we're after:
# https://github.com/tox-dev/tox/pull/1202
minversion = 3.8.0
mypy_version = 1.11.2
ruff_version = 0.6.5
pytest_version = 8.2.2
setuptools_version = 74.1.2
envlist=
version.py
ruff-format
mypy
ruff-check
shellcheck
installtest
pytest
package, test-package
test-wheel
[testenv]
skip_install = true
basepython = python3
allowlist_externals = /bin/bash
[testenv:version.py]
deps =
setuptools == {[tox]setuptools_version}
commands =
# This keeps px/version.py up to date
/bin/bash -c './devbin/update_version_py.py'
[testenv:ruff-format]
deps =
ruff=={[tox]ruff_version}
# Format locally, check in CI and fail on not-formatted code
commands = /bin/bash -c 'if [ "{env:CI:}" ] ; then CHECK="--check --diff" ; fi ; ruff format $CHECK ./*.py ./*/*.py'
[testenv:mypy]
# NOTE: In theory mypy should probably depend on ruff-format to get line numbers
# in any error messages right. But since mypy tends to finish last, and being a
# bit off isn't the end of the world, let's not depend on ruff-format for now
# and hope nobody notices.
depends = version.py
deps =
mypy=={[tox]mypy_version}
pytest=={[tox]pytest_version}
types-setuptools==67.7.0.1 # Matches what was on Johan's laptop 2023-05-08
types-python-dateutil==2.8.19
commands =
/bin/bash -c 'mypy --pretty ./*.py ./*/*.py'
[testenv:ruff-check]
# Depend on ruff-format to not complain about formatting errors
depends = version.py, ruff-format
deps =
ruff=={[tox]ruff_version}
pytest=={[tox]pytest_version}
# Auto-fix locally but not in CI
commands =
/bin/bash -c 'FIX="--fix" ; if [ "{env:CI:}" ] ; then FIX="--no-fix" ; fi ; ruff check $FIX ./*.py ./*/*.py'
[testenv:shellcheck]
commands =
/bin/bash -c 'shellcheck ./*.sh ./*/*.sh'
[testenv:installtest]
allowlist_externals = {toxinidir}/tests/installtest.sh
commands =
{toxinidir}/tests/installtest.sh
[testenv:pytest]
depends = version.py, ruff-format
deps =
pytest == {[tox]pytest_version}
pytest-avoidance == 0.3.0
python-dateutil >= 2.6.1
commands =
pytest --durations=10 --color=yes tests
[testenv:package]
# Create {toxinidir}/px.pex
depends = version.py, ruff-format
allowlist_externals = {toxinidir}/devbin/make-executable-zip.sh
deps =
# Used by the make-executable-zip.sh script
virtualenv
commands =
{toxinidir}/devbin/make-executable-zip.sh
[testenv:test-package]
depends = package
commands =
# Verify we have the correct shebang
/bin/bash -c 'head -n1 {toxinidir}/px.pex | grep -Eq "^\#!/usr/bin/env python3$"'
# Test that there are no natively compiled dependencies. They make
# distribution a lot harder. If this triggers, fix your dependencies!
/bin/bash -c '! unzip -qq -l "{toxinidir}/px.pex" "*.so"'
# Run pex and ensure it doesn't fail
python -Werror {toxinidir}/px.pex
# Test version string vs git
/bin/bash -x -c 'test "$("{toxinidir}/px.pex" --version)" = "$(git describe --dirty)"'
[testenv:test-wheel]
# Test installing using pip
depends = version.py, ruff-format
allowlist_externals =
/bin/bash
/bin/rm
deps =
setuptools == {[tox]setuptools_version}
build == 1.2.2
commands =
# clean up build/ and dist/ folders
/bin/rm -rf build dist
# build wheel
python -m build --outdir {toxinidir}/dist
# Start testing it
/bin/bash -c "pip uninstall --yes pxpx"
/bin/bash -c "pip install {toxinidir}/dist/pxpx-*.whl"
# Verify we can run the px we just installed using pip
px tox
# Test version string vs git
/bin/bash -x -c 'test "$(px --version)" = "$(git describe --dirty)"'