-
Notifications
You must be signed in to change notification settings - Fork 1
/
tox.ini
135 lines (120 loc) · 3.89 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
[tox]
envlist = lint,default-{mssql,pgsql}
source_package=fastapi_batteries_included
all_sources = {[tox]source_package} tests/
skipsdist = True
requires = tox-venv
tox-docker>=2.0.0a3
tox-pip-version
provision_tox_env=provision
database_user=fastapi_batteries
database_password=YourSTRONG!Passw0rd
database_db=fastapi_batteries_db
[flake8]
max-line-length = 100
[docker:pgsql]
image = postgres:12-alpine
environment =
POSTGRES_USER={[tox]database_user}
POSTGRES_DB={[tox]database_db}
POSTGRES_PASSWORD={[tox]database_password}
# The healthcheck ensures that tox-docker won't run tests until the
# container is up and the command finishes with exit code 0 (success)
healthcheck_cmd = PGPASSWORD=$POSTGRES_PASSWORD psql \
--user=$POSTGRES_USER --dbname=$POSTGRES_DB \
--host=127.0.0.1 --quiet --no-align --tuples-only \
-1 --command="SELECT 1"
healthcheck_timeout = 1
healthcheck_retries = 30
healthcheck_interval = 1
healthcheck_start_period = 1
[docker:mssql]
image = mcr.microsoft.com/mssql/server:2019-latest
environment =
MSSQL_PID=Express
ACCEPT_EULA=Y
MSSQL_SA_PASSWORD={[tox]database_password}
healthcheck_cmd = /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $MSSQL_SA_PASSWORD -b -Q "SELECT 1"
healthcheck_interval = 1
healthcheck_start_period = 1
healthcheck_retries = 20
healthcheck_timeout = 1
[testenv:provision]
envdir={toxworkdir}/.provision
[testenv:default-{pgsql,mssql}]
description = Installs all dependencies, verifies that lint tools would not change the code,
runs security check programs then runs unit tests with coverage. Running `tox -e py39`
does the same but without starting a database container.
docker =
pgsql: pgsql
mssql: mssql
setenv= {[testenv]setenv}
[testenv]
envdir = {toxworkdir}/py39
pip_version = pip>=21.1.1
skip_install = true
passenv =
CIRCLECI
PIP_EXTRA_INDEX_URL
DATABASE_HOST
DATABASE_PORT
PGSQL_HOST
PGSQL_5432_TCP_PORT
MSSQL_HOST
MSSQL_1433_TCP_PORT
setenv = ENVIRONMENT = DEVELOPMENT
ACCEPTED_API_KEY = TopSecret
AUTH_PROVIDER_AUDIENCE = https://dhos-dev.sensynehealth.com/
AUTH_PROVIDER_DOMAIN = https://draysonhealth.eu.auth0.com/"
AUTH_PROVIDER_METADATA = https://gdm.draysonhealth.com/metadata
AUTH_PROVIDER_SCOPE_KEY = https://gdm.sensynehealth.com/scope
AUTH_PROVIDER_JWKS_URL = https://login-sandbox.sensynehealth.com/.well-known/jwks.json
HS_KEY = secret
PROXY_URL = http://localhost
DATABASE_USER=fastapi_batteries
pgsql: RUN_POSTGRES_TESTS=True
DATABASE_PASSWORD=YourSTRONG!Passw0rd
mssql: RUN_MSSQL_TESTS=True
DATABASE_NAME=fastapi_batteries_db
LOG_FORMAT=colour
LOG_LEVEL=DEBUG
NOPROXY=*
commands_pre =
poetry install -E pgsql -E mssql -E jwt
mssql: bash tests/create_ms_database.sh
commands =
bandit -r {[tox]source_package} -lll
safety check
black --check {[tox]source_package} tests
isort --profile black {[tox]source_package} tests/ --check-only
mypy {[tox]source_package}
coverage run --source {[tox]source_package} -m py.test {posargs}
coverage report
coverage xml -i -o coverage-reports/coverage.xml
allowlist_externals =
bandit
bash
black
coverage
isort
mypy
poetry
python
safety
true
list_dependencies_command = true
[testenv:lint]
description = Run black, isort, and mypy to clean up source files
commands =
black {[tox]all_sources}
isort --profile black {[tox]all_sources}
mypy {[tox]source_package} tests/
[testenv:debug]
description = Run last failing unit test and invoke debugger on errors
commands =
pytest {posargs:--lf --pdb}
docker = pgsql
setenv= {[testenv]setenv}
[testenv:update]
description = Update poetry lock files
commands = poetry update