forked from patroni/patroni
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tox.ini
252 lines (234 loc) · 6.11 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
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
[common]
python_matrix = {36,37,38,39,310,311}
postgres_matrix =
pg11: PG_MAJOR = 11
pg12: PG_MAJOR = 12
pg13: PG_MAJOR = 13
pg14: PG_MAJOR = 14
pg15: PG_MAJOR = 15
pg16: PG_MAJOR = 16
psycopg_deps =
py{37,38,39,310,311}-{lin,win}: psycopg[binary]
mac: psycopg2-binary
py36: psycopg2-binary
platforms =
lin: linux
mac: darwin
win: win32
[tox]
min_version = 4.0
requires =
tox>4
env_list =
dep
lint
py{[common]python_matrix}-test-{lin,mac,win}
docs
skipsdist = True
toxworkdir = {env:TOX_WORK_DIR:.tox}
skip_missing_interpreters = True
[testenv]
setenv =
PYTHONDONTWRITEBYTECODE = 1
mac: OPEN_CMD = {env:OPEN_CMD:open}
lin: OPEN_CMD = {env:OPEN_CMD:xdg-open}
passenv =
BROWSER
DISPLAY
[testenv:lint]
description = Lint code with flake8
commands = flake8 {posargs:patroni tests setup.py}
deps =
flake8
[testenv:py{36,37,38,39,310,311}-test-{lin,win,mac}]
description = Run unit tests with pytest
labels =
test
commands_pre =
- {tty:rm -f "{toxworkdir}{/}cov_report_{env_name}_html{/}index.html":true}
- {tty:rm -f "{toxworkdir}{/}pytest_report_{env_name}.html":true}
commands =
pytest \
-p no:cacheprovider \
--verbose \
--doctest-modules \
--capture=fd \
--cov=patroni \
--cov-report=term-missing \
--cov-append \
{tty::--cov-report="xml\:{toxworkdir}{/}cov_report.{env_name}.xml"} \
{tty:--cov-report="html\:{toxworkdir}{/}cov_report_{env_name}_html":} \
{tty:--html="{toxworkdir}{/}pytest_report_{env_name}.html":} \
{posargs:tests patroni}
commands_post =
- {tty:{env:OPEN_CMD} "{toxworkdir}{/}cov_report_{env_name}_html{/}index.html":true}
- {tty:{env:OPEN_CMD} "{toxworkdir}{/}pytest_report_{env_name}.html":true}
deps =
-r requirements.txt
pytest
pytest-cov
pytest-html
{[common]psycopg_deps}
platform =
{[common]platforms}
allowlist_externals =
rm
true
{env:OPEN_CMD}
[testenv:dep]
description = Check package dependency problems
commands = pipdeptree -w fail
deps =
-r requirements.txt
pipdeptree
{[common]psycopg_deps}
[testenv:py{37,38,39,310,311}-type-{lin,mac,win}]
description = Run static type checking with pyright
labels =
type
deps =
-r requirements.txt
pyright
psycopg2-binary
psycopg[binary]
commands = pyright --venv-path {toxworkdir}{/}{envname} {posargs:patroni}
platform =
{[common]platforms}
[testenv:black]
description = Reformat code with black
deps = black
commands = black {posargs:patroni tests}
[testenv:pg{12,13,14,15,16}-docker-build]
description = Build docker containers needed for testing
labels =
behave
docker-build
setenv =
{[common]postgres_matrix}
DOCKER_BUILDKIT = 1
passenv =
BASE_IMAGE
commands =
docker build . \
--tag patroni-dev:{env:PG_MAJOR} \
--build-arg PG_MAJOR \
--build-arg BASE_IMAGE={env:BASE_IMAGE:postgres} \
--file features/Dockerfile
allowlist_externals = docker
[testenv:pg{12,13,14,15,16}-docker-behave-{etcd,etcd3}-{lin,mac}]
description = Run behaviour tests in patroni-dev docker container
setenv =
etcd: DCS=etcd
etcd3: DCS=etcd3
{[common]postgres_matrix}
CONTAINER_NAME = tox-{env_name}-{env:PYTHONHASHSEED}
labels =
behave
depends =
pg{11,12,13,14,15,16}-docker-build
# There's a bug which affects calling multiple envs on the command line
# This should be a valid command: tox -e 'py{36,37,38,39,310,311}-behave-{env:DCS}-lin'
# Replaced with workaround, see https://github.com/tox-dev/tox/issues/2850
commands =
docker run \
--volume {tox_root}:/src \
--env DCS={env:DCS} \
--hostname {env:CONTAINER_NAME} \
--name {env:CONTAINER_NAME} \
--rm \
--tty \
{env:PATRONI_DEV_IMAGE:patroni-dev:{env:PG_MAJOR}} \
tox run -x 'tox.env_list=py{[common]python_matrix}-behave-{env:DCS}-lin' \
-- {posargs}
allowlist_externals =
docker
find
platform =
lin: linux
; win: win32
mac: darwin
[testenv:py{36,38,39,310,311}-behave-{etcd,etcd3}-{lin,win,mac}]
description = Run behaviour tests (locally with tox)
deps =
-r requirements.txt
behave
coverage
{[common]psycopg_deps}
setenv =
etcd: DCS = {env:DCS:etcd}
etcd3: DCS = {env:DCS:etcd3}
passenv =
ETCD_UNSUPPORTED_ARCH
commands =
python3 -m behave --format json --format plain --outfile result.json {posargs}
mv result.json features/output
allowlist_externals =
mv
platform =
{[common]platforms}
[testenv:epub-{lin,mac,win}]
description = Build Sphinx documentation in epub format
labels:
docs
deps =
-r requirements.docs.txt
-r requirements.txt
commands =
python -m sphinx -T -b epub -d _build/doctrees -D language=en . epub
allowlist_externals =
true
{env:OPEN_CMD}
platform =
{[common]platforms}
change_dir = docs
[testenv:docs-{lin,mac,win}]
description = Build Sphinx documentation in HTML format
labels:
docs
deps =
-r requirements.docs.txt
-r requirements.txt
commands =
sphinx-build \
-d "{envtmpdir}{/}doctree" docs "{toxworkdir}{/}docs_out" \
--color -b html \
-T -E -W --keep-going \
{posargs}
commands_post =
- {tty:{env:OPEN_CMD} "{toxworkdir}{/}docs_out{/}index.html":true:}
allowlist_externals =
true
{env:OPEN_CMD}
platform =
{[common]platforms}
[testenv:pdf-{lin,mac,win}]
description = Build Sphinx documentation in PDF format
labels:
docs
deps =
-r requirements.docs.txt
-r requirements.txt
commands =
python -m sphinx -T -E -b latex -d _build/doctrees -D language=en . pdf
- latexmk -r pdf/latexmkrc -cd -C pdf/Patroni.tex
latexmk -r pdf/latexmkrc -cd -pdf -f -dvi- -ps- -jobname=Patroni -interaction=nonstopmode pdf/Patroni.tex
commands_post =
- {tty:{env:OPEN_CMD} "pdf{/}Patroni.pdf":true:}
allowlist_externals =
true
latexmk
{env:OPEN_CMD}
platform =
{[common]platforms}
change_dir = docs
[flake8]
max-line-length = 120
ignore = D401,W503
[isort]
line_length = 120
multi_line_output = 2
balanced_wrapping = true
combine_as_imports = true
force_alphabetical_sort_within_sections = true
lines_between_types = 1
known_third_party = consul