-
Notifications
You must be signed in to change notification settings - Fork 274
/
tox.ini
240 lines (197 loc) · 8.25 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
[tox]
skip_missing_interpreters = true
envlist =
sphinx
flake8
mypy
yapf
bandit
pytest
{py311,pypy39}-{pinned,unpinned,abtrunk}-trial
{py311,pypy39}-examples
functests-cb
functests-cfc
{py311,pypy39}-api-1
{py311,pypy39}-cli-0
{py311,pypy39}-cli-1
{py311,pypy39}-cli-2
{py311,pypy39}-cli-3
{py311,pypy39}-automate-1
{py311,pypy39}-automate-2
{py311,pypy39}-xbrnetwork-1
# MAP: GitHub Actions Python Name => Tox Env Name (for Python)
#
# when called without a specific environment ("-e"), detect the
# python version / get from GH action, and map to tox env
#
# https://github.com/ymyzk/tox-gh-actions
#
[gh-actions]
python =
3.11: py311
pypy-3.9: pypy39
[testenv]
description =
Common environment.
# yes, we do want to skip the installation of the package, because we do that ourself
skip_install = True
allowlist_externals = *
setenv =
PYTHONPATH = {toxinidir}
CB_FULLTESTS = {env:CB_FULLTESTS:1}
XBR_FULLTESTS = {env:XBR_FULLTESTS:1}
# Crossbar.io build vars
CROSSBAR_BUILD_DATE = {env:CROSSBAR_BUILD_DATE:1900-01-01}
CROSSBAR_BUILD_ID = {env:CROSSBAR_BUILD_ID:19000101-0000000}
CROSSBAR_VCS_REF = {env:CROSSBAR_VCS_REF:0000000}
CROSSBAR_VERSION = {env:CROSSBAR_VERSION:1.1.1}
# seed phrase to run Ganache (test blockchain)
XBR_HDWALLET_SEED = {env:XBR_HDWALLET_SEED:"none none none"}
# Infura account
INFURA_PROJECT_ID = {env:INFURA_PROJECT_ID:"00000000000000000000000000000000"}
INFURA_PROJECT_SECRET = {env:INFURA_PROJECT_SECRET:"00000000000000000000000000000000"}
# XBR contract addresses
XBR_DEBUG_TOKEN_ADDR = {env:XBR_DEBUG_TOKEN_ADDR:0x0000000000000000000000000000000000000000}
XBR_DEBUG_NETWORK_ADDR = {env:XBR_DEBUG_NETWORK_ADDR:0x0000000000000000000000000000000000000000}
XBR_DEBUG_MARKET_ADDR = {env:XBR_DEBUG_MARKET_ADDR:0x0000000000000000000000000000000000000000}
XBR_DEBUG_CATALOG_ADDR = {env:XBR_DEBUG_CATALOG_ADDR:0x0000000000000000000000000000000000000000}
XBR_DEBUG_CHANNEL_ADDR = {env:XBR_DEBUG_CHANNEL_ADDR:0x0000000000000000000000000000000000000000}
# for running tests
MAILGUN_KEY = "key-00000000000000000000000000000000"
MAILGUN_URL = "https://api.mailgun.net/v3/mailing.crossbar.io/messages"
CROSSBAR_FABRIC_URL = {env:CROSSBAR_FABRIC_URL:ws://localhost:9000/ws}
# use superuser key from node directory (NOT recommended in prod):
CROSSBAR_FABRIC_SUPERUSER = {toxinidir}/test/cfc/.crossbar/default.pub
passenv =
# https://packaging.python.org/guides/supporting-windows-using-appveyor/#testing-with-tox
DISTUTILS_USE_SDK
MSSdk
INCLUDE
LIB
HOME
commands =
pip show pip
# Install development dependencies
pip install -r {toxinidir}/requirements-dev.txt
# Install package dependencies
pip install -U --force-reinstall -r {toxinidir}/requirements-latest.txt
# Install the package itself
pip install .
# inject build ID into source code: modifies CROSSBAR/_version.py!
echo "Building with CROSSBAR_BUILD_ID={env:CROSSBAR_BUILD_ID}"
python inject-build-id.py
# print effective version/build
python -c "from crossbar._version import __version__, __build__; print('crossbar==', __version__, __build__)"
# check basic personality import
python -c "import txaio; txaio.use_twisted(); from crossbar import edge, master"
# check full version output
crossbar version
# generate default profile
echo "Testing with CROSSBAR_FABRIC_URL={env:CROSSBAR_FABRIC_URL}, CROSSBAR_FABRIC_SUPERUSER={env:CROSSBAR_FABRIC_SUPERUSER}"
crossbar shell init --yes
# in envs with "examples", run autobahn examples via test shell script
examples: {toxinidir}/test/test_ab_examples.sh
# in envs with "trial", run Twisted trial
trial: python -m twisted.trial crossbar
# run CE tests
# pytest: pytest crossbar/edge/node/tests/
pytest: pytest -sv crossbar
# run functional tests
functests-cb: pytest -sv --no-install {toxinidir}/test/functests/cbtests
functests-cfc: sh -c '{toxinidir}/test/test_setup.sh && pytest -sv --no-install {toxinidir}/test/functests/cfctests'
# run (in envs with "cli") crossbar CLI via a test shell scripts
cli-0: {toxinidir}/test/test_cli_0.sh
cli-1: {toxinidir}/test/test_cli_1.sh
cli-2: {toxinidir}/test/test_cli_2.sh
cli-3: {toxinidir}/test/test_cli_3.sh
# python client scripts calling into CFC management API
api-1: {toxinidir}/test/management/run.sh
# master node + CLI based functional test (webcluster + routercluster)
automate-1: sh -c 'cd {toxinidir}/test/test_automated && ./test_prepare_host.sh && ./test_setup1.sh && ./test_host1.sh 1'
automate-2: sh -c 'cd {toxinidir}/test/test_automated && ./test_prepare_host.sh && ./test_setup2.sh && ./test_host2.sh 1'
# blockchain (with xbr) + edge node (with xbr network backend) + client tests (autobahn)
xbrnetwork-1: sh -c 'cd {toxinidir}/test/test_xbr_network && ./test_xbr_network.sh 1'
[testenv:sphinx]
description =
Generate docs using Sphinx.
skip_install = True
allowlist_externals = *
commands =
# first test with all warnings fatal
sphinx-build -nWT -b dummy ./docs ./docs/_build
# run spell checker
sphinx-build -b spelling -q -d ./docs/_build/doctrees ./docs ./docs/_build/spelling
# generate HTML output
sphinx-build -b dirhtml ./docs ./docs/_build
[testenv:bandit]
skip_install = True
changedir = {toxinidir}
exclude = crossbar/worker/test/examples/syntaxerror.py
deps =
bandit
commands =
bandit -r -s B101,B110,B311 \
-x crossbar/common/key.py,crossbar/bridge/mqtt/test/test_wamp.py,crossbar/bridge/rest/test/__init__.py,crossbar/bridge/mqtt/test/test_wamp.py,crossbar/webservice/misc.py \
crossbar
[testenv:flake8]
skip_install = True
changedir = {toxinidir}
exclude = crossbar/worker/test/examples/syntaxerror.py
deps =
flake8
commands =
flake8 \
--exclude crossbar/shell/reflection \
--ignore=E501,E402,E722,E741,W503,W504,E126,E251 \
crossbar
[testenv:yapf]
description =
Run yapf style checks.
skip_install = True
deps =
yapf==0.29.0
commands =
yapf --version
yapf -rd \
--style={toxinidir}/yapf.ini \
--exclude="crossbar/shell/reflection/*" \
--exclude="crossbar/master/database/*" \
--exclude="crossbar/edge/database/*" \
--exclude="crossbar/shell/repl.py" \
--exclude="crossbar/worker/test/examples/syntaxerror.py" \
crossbar
[testenv:mypy]
description =
Run mypy type checks.
skip_install = True
deps =
mypy
commands=
mypy \
--exclude '(test_.*\.py)|(syntaxerror\.py)' \
--ignore-missing-imports \
crossbar
[testenv:coverage]
skip_install = False
changedir = {toxinidir}
commands =
# unit tests
coverage run --rcfile={toxinidir}/.coveragerc -m twisted.trial crossbar
# integration tests
rm -rf /tmp/test
coverage run --rcfile={toxinidir}/.coveragerc test/run_crossbar.py version
coverage run --rcfile={toxinidir}/.coveragerc test/run_crossbar.py init --appdir /tmp/test
coverage run --rcfile={toxinidir}/.coveragerc test/run_crossbar.py status --cbdir /tmp/test/.crossbar
coverage run --rcfile={toxinidir}/.coveragerc test/run_crossbar.py start --cbdir /tmp/test/.crossbar --shutdownafter=5
coverage run --rcfile={toxinidir}/.coveragerc test/run_crossbar.py convert --cbdir /tmp/test/.crossbar
coverage run --rcfile={toxinidir}/.coveragerc test/run_crossbar.py start --cbdir /tmp/test/.crossbar --shutdownafter=5
# test a node with all features ("full configuration")
coverage run --rcfile={toxinidir}/.coveragerc test/run_crossbar.py start --cbdir {toxinidir}/test/full/.crossbar --shutdownafter=15
# create coverage report
coverage combine --rcfile={toxinidir}/.coveragerc
coverage report --rcfile={toxinidir}/.coveragerc --omit="*/syntaxerror.py" --omit="*/test/*.py"
coverage html --rcfile={toxinidir}/.coveragerc --omit="*/syntaxerror.py" --omit="*/test/*.py"
setenv =
COVERAGE_PROCESS_START = {toxinidir}/.coveragerc
COVERAGE_FILE = {toxinidir}/.coverage
{py311,pypy39}: CB_FULLTESTS = 1