mirror of
https://github.com/optim-enterprises-bv/patroni.git
synced 2026-01-08 16:41:30 +00:00
Besides that: 1. Introduce `setup.py isort` for quick check 2. Introduce GH actions to check imports
253 lines
6.1 KiB
INI
253 lines
6.1 KiB
INI
[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
|