-
Notifications
You must be signed in to change notification settings - Fork 1
/
tox.ini
executable file
·134 lines (112 loc) · 3.67 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
[tox]
skipsdist = True
envlist = lint,default
source_package=dhos_sms_api
all_sources = {[tox]source_package} tests/ docs/
requires = tox-venv
tox-docker>=2.0.0a3
provision_tox_env=provision
[flake8]
max-line-length = 100
[docker:db]
image = postgres:12-alpine
environment =
POSTGRES_USER=dhos-sms
POSTGRES_DB=dhos-sms
POSTGRES_PASSWORD=TopSecretPassword
ports=15432:5432/tcp
[testenv:provision]
envdir={toxworkdir}/.provision
[testenv:poetry-install]
commands = poetry install
[testenv:default]
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 = db
setenv= {[testenv]setenv}
DATABASE_HOST=localhost
DATABASE_PORT=15432
[testenv]
envdir = {toxworkdir}/py39
setenv = ENVIRONMENT = DEVELOPMENT
LOG_FORMAT = COLOUR
LOG_LEVEL = DEBUG
TWILIO_CALL_BACK_URL = http://dummy-callback-url
COUNTRY_CODE = GB
TWILIO_ACCOUNT_SID = something
TWILIO_AUTH_TOKEN = something
TWILIO_DISABLED = true
FLASK_APP={[tox]source_package}/autoapp.py
DATABASE_USER=dhos-sms
DATABASE_PASSWORD=TopSecretPassword
DATABASE_NAME=dhos-sms
passenv =
CIRCLECI
PIP_EXTRA_INDEX_URL
DATABASE_HOST
DATABASE_PORT
allowlist_externals =
bandit
black
coverage
isort
mypy
npx
poetry
python
safety
sh
true
commands = poetry install
black --check {[tox]source_package} tests/
isort --profile black {[tox]source_package}/ tests/ --check-only
mypy {[tox]source_package} tests/
bandit -r {[tox]source_package} -lll
safety check
coverage run --source {[tox]source_package} -m py.test {posargs}
coverage report
coverage xml -i -o coverage-reports/coverage.xml
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/ docs/
[testenv:debug]
description = Runs last failed unit tests only with debugger invoked on failure.
Additional py.test command line arguments may given preceded by `--`,
e.g. `tox -e debug -- -k sometestname -vv`
commands =
pytest --lf --pdb {posargs}
docker = db
setenv = {[testenv:default]setenv}
SQLALCHEMY_ECHO=true
[testenv:update]
description = Updates the `poetry.lock` file from `pyproject.toml`
commands = poetry update
[testenv:openapi]
description = Recreate API specification (openapi.yaml) from Flask blueprint
commands =
poetry install
python -m flask create-openapi {toxinidir}/{[tox]source_package}/openapi/openapi.yaml
npx markdown-swagger {toxinidir}/{[tox]source_package}/openapi/openapi.yaml {toxinidir}/README.md
docker = db
setenv = {[testenv:default]setenv}
[testenv:flask]
description = Runs flask within the tox environment. Pass arguments after `--`.
e.g. `tox -e flask -- --help` for a list of commands.
Use this to create database migrations.
commands =
poetry install
python -m flask db upgrade
python -m flask {posargs:--help}
docker = db
setenv = {[testenv:default]setenv}
[testenv:readme]
description = Updates the README file with database diagram and commands. (Requires graphviz `dot` is installed)
requires=sadisplay
commands =
python docs/make_schema.py
python docs/make-targets.py README.md