1
0

tox.ini 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. [tox]
  2. envlist = packaging, py35, py36, py37, py38, check_codestyle, check_isort
  3. [base]
  4. deps =
  5. mock
  6. python-subunit
  7. junitxml
  8. coverage
  9. coverage-enable-subprocess
  10. parameterized
  11. # cyptography 2.2 requires setuptools >= 18.5
  12. #
  13. # older versions of virtualenv (?) give us a virtualenv with the same
  14. # version of setuptools as is installed on the system python (and tox runs
  15. # virtualenv under python3, so we get the version of setuptools that is
  16. # installed on that).
  17. #
  18. # anyway, make sure that we have a recent enough setuptools.
  19. setuptools>=18.5
  20. # we also need a semi-recent version of pip, because old ones fail to
  21. # install the "enum34" dependency of cryptography.
  22. pip>=10
  23. setenv =
  24. # we have a pyproject.toml, but don't want pip to use it for building.
  25. # (otherwise we get an error about 'editable mode is not supported for
  26. # pyproject.toml-style projects').
  27. PIP_USE_PEP517 = false
  28. PYTHONDONTWRITEBYTECODE = no_byte_code
  29. COVERAGE_PROCESS_START = {toxinidir}/.coveragerc
  30. [testenv]
  31. deps =
  32. {[base]deps}
  33. extras = all
  34. whitelist_externals =
  35. sh
  36. setenv =
  37. {[base]setenv}
  38. postgres: SYNAPSE_POSTGRES = 1
  39. TOP={toxinidir}
  40. passenv = *
  41. commands =
  42. /usr/bin/find "{toxinidir}" -name '*.pyc' -delete
  43. # Add this so that coverage will run on subprocesses
  44. {envbindir}/coverage run "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  45. # As of twisted 16.4, trial tries to import the tests as a package (previously
  46. # it loaded the files explicitly), which means they need to be on the
  47. # pythonpath. Our sdist doesn't include the 'tests' package, so normally it
  48. # doesn't work within the tox virtualenv.
  49. #
  50. # As a workaround, we tell tox to do install with 'pip -e', which just
  51. # creates a symlink to the project directory instead of unpacking the sdist.
  52. #
  53. # (An alternative to this would be to set PYTHONPATH to include the project
  54. # directory. Note two problems with this:
  55. #
  56. # - if you set it via `setenv`, then it is also set during the 'install'
  57. # phase, which inhibits unpacking the sdist, so the virtualenv isn't
  58. # useful for anything else without setting PYTHONPATH similarly.
  59. #
  60. # - `synapse` is also loaded from PYTHONPATH so even if you only set
  61. # PYTHONPATH for the test phase, we're still running the tests against
  62. # the working copy rather than the contents of the sdist. So frankly
  63. # you might as well use -e in the first place.
  64. #
  65. # )
  66. usedevelop=true
  67. # A test suite for the oldest supported versions of Python libraries, to catch
  68. # any uses of APIs not available in them.
  69. [testenv:py35-old]
  70. skip_install=True
  71. deps =
  72. # Old automat version for Twisted
  73. Automat == 0.3.0
  74. mock
  75. lxml
  76. coverage
  77. coverage-enable-subprocess
  78. commands =
  79. /usr/bin/find "{toxinidir}" -name '*.pyc' -delete
  80. # Make all greater-thans equals so we test the oldest version of our direct
  81. # dependencies, but make the pyopenssl 17.0, which can work against an
  82. # OpenSSL 1.1 compiled cryptography (as older ones don't compile on Travis).
  83. /bin/sh -c 'python -m synapse.python_dependencies | sed -e "s/>=/==/g" -e "s/psycopg2==2.6//" -e "s/pyopenssl==16.0.0/pyopenssl==17.0.0/" | xargs -d"\n" pip install'
  84. # Install Synapse itself. This won't update any libraries.
  85. pip install -e .
  86. {envbindir}/coverage run "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  87. [testenv:benchmark]
  88. deps =
  89. {[base]deps}
  90. pyperf
  91. setenv =
  92. SYNAPSE_POSTGRES = 1
  93. commands =
  94. python -m synmark {posargs:}
  95. [testenv:packaging]
  96. skip_install=True
  97. deps =
  98. check-manifest
  99. commands =
  100. check-manifest
  101. [testenv:check_codestyle]
  102. skip_install = True
  103. deps =
  104. flake8
  105. flake8-comprehensions
  106. # We pin so that our tests don't start failing on new releases of black.
  107. black==19.10b0
  108. commands =
  109. python -m black --check --diff .
  110. /bin/sh -c "flake8 synapse tests scripts scripts-dev contrib synctl {env:PEP8SUFFIX:}"
  111. {toxinidir}/scripts-dev/config-lint.sh
  112. [testenv:check_isort]
  113. skip_install = True
  114. deps = isort==5.0.3
  115. commands = /bin/sh -c "isort -c --df --sp setup.cfg synapse tests scripts-dev scripts"
  116. [testenv:check-newsfragment]
  117. skip_install = True
  118. deps = towncrier>=18.6.0rc1
  119. commands =
  120. python -m towncrier.check --compare-with=origin/develop
  121. [testenv:check-sampleconfig]
  122. commands = {toxinidir}/scripts-dev/generate_sample_config --check
  123. [testenv:combine]
  124. skip_install = True
  125. deps =
  126. coverage
  127. commands=
  128. coverage combine
  129. coverage report
  130. [testenv:cov-erase]
  131. skip_install = True
  132. deps =
  133. coverage
  134. commands=
  135. coverage erase
  136. [testenv:cov-html]
  137. skip_install = True
  138. deps =
  139. coverage
  140. commands=
  141. coverage html
  142. [testenv:mypy]
  143. skip_install = True
  144. deps =
  145. {[base]deps}
  146. mypy==0.750
  147. mypy-zope
  148. env =
  149. MYPYPATH = stubs/
  150. extras = all
  151. commands = mypy \
  152. synapse/api \
  153. synapse/appservice \
  154. synapse/config \
  155. synapse/event_auth.py \
  156. synapse/events/builder.py \
  157. synapse/events/spamcheck.py \
  158. synapse/federation \
  159. synapse/handlers/auth.py \
  160. synapse/handlers/cas_handler.py \
  161. synapse/handlers/directory.py \
  162. synapse/handlers/federation.py \
  163. synapse/handlers/identity.py \
  164. synapse/handlers/message.py \
  165. synapse/handlers/oidc_handler.py \
  166. synapse/handlers/presence.py \
  167. synapse/handlers/room_member.py \
  168. synapse/handlers/room_member_worker.py \
  169. synapse/handlers/saml_handler.py \
  170. synapse/handlers/sync.py \
  171. synapse/handlers/ui_auth \
  172. synapse/http/server.py \
  173. synapse/http/site.py \
  174. synapse/logging/ \
  175. synapse/metrics \
  176. synapse/module_api \
  177. synapse/notifier.py \
  178. synapse/push/pusherpool.py \
  179. synapse/push/push_rule_evaluator.py \
  180. synapse/replication \
  181. synapse/rest \
  182. synapse/server.py \
  183. synapse/server_notices \
  184. synapse/spam_checker_api \
  185. synapse/storage/databases/main/ui_auth.py \
  186. synapse/storage/database.py \
  187. synapse/storage/engines \
  188. synapse/storage/state.py \
  189. synapse/storage/util \
  190. synapse/streams \
  191. synapse/types.py \
  192. synapse/util/caches/stream_change_cache.py \
  193. synapse/util/metrics.py \
  194. tests/replication \
  195. tests/test_utils \
  196. tests/rest/client/v2_alpha/test_auth.py \
  197. tests/util/test_stream_change_cache.py
  198. # To find all folders that pass mypy you run:
  199. #
  200. # find synapse/* -type d -not -name __pycache__ -exec bash -c "mypy '{}' > /dev/null" \; -print