tox.ini 6.4 KB

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