1
0

tox.ini 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. [tox]
  2. envlist = packaging, py36, py37, py38, py39, check_codestyle, check_isort
  3. # we require tox>=2.3.2 for the fix to https://github.com/tox-dev/tox/issues/208
  4. minversion = 2.3.2
  5. [base]
  6. deps =
  7. python-subunit
  8. junitxml
  9. coverage
  10. # this is pinned since it's a bit of an obscure package.
  11. coverage-enable-subprocess==1.0
  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. # directories/files we run the linters on.
  25. # if you update this list, make sure to do the same in scripts-dev/lint.sh
  26. lint_targets =
  27. setup.py
  28. synapse
  29. tests
  30. scripts
  31. # annoyingly, black doesn't find these so we have to list them
  32. scripts/export_signing_key
  33. scripts/generate_config
  34. scripts/generate_log_config
  35. scripts/hash_password
  36. scripts/register_new_matrix_user
  37. scripts/synapse_port_db
  38. scripts-dev
  39. scripts-dev/build_debian_packages
  40. scripts-dev/sign_json
  41. scripts-dev/update_database
  42. stubs
  43. contrib
  44. synctl
  45. synmark
  46. .ci
  47. docker
  48. # default settings for all tox environments
  49. [testenv]
  50. deps =
  51. {[base]deps}
  52. extras =
  53. # install the optional dependendencies for tox environments without
  54. # '-noextras' in their name
  55. # (this requires tox 3)
  56. !noextras: all
  57. test
  58. setenv =
  59. # use a postgres db for tox environments with "-postgres" in the name
  60. # (see https://tox.readthedocs.io/en/3.20.1/config.html#factors-and-factor-conditional-settings)
  61. postgres: SYNAPSE_POSTGRES = 1
  62. # this is used by .coveragerc to refer to the top of our tree.
  63. TOP={toxinidir}
  64. passenv = *
  65. commands =
  66. # the "env" invocation enables coverage checking for sub-processes. This is
  67. # particularly important when running trial with `-j`, since that will make
  68. # it run tests in a subprocess, whose coverage would otherwise not be
  69. # tracked. (It also makes an explicit `coverage run` command redundant.)
  70. #
  71. # (See https://coverage.readthedocs.io/en/coverage-5.3/subprocess.html.
  72. # Note that the `coverage.process_startup()` call is done by
  73. # `coverage-enable-subprocess`.)
  74. #
  75. # we use "env" rather than putting a value in `setenv` so that it is not
  76. # inherited by other tox environments.
  77. #
  78. /usr/bin/env COVERAGE_PROCESS_START={toxinidir}/.coveragerc "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  79. # As of twisted 16.4, trial tries to import the tests as a package (previously
  80. # it loaded the files explicitly), which means they need to be on the
  81. # pythonpath. Our sdist doesn't include the 'tests' package, so normally it
  82. # doesn't work within the tox virtualenv.
  83. #
  84. # As a workaround, we tell tox to do install with 'pip -e', which just
  85. # creates a symlink to the project directory instead of unpacking the sdist.
  86. #
  87. # (An alternative to this would be to set PYTHONPATH to include the project
  88. # directory. Note two problems with this:
  89. #
  90. # - if you set it via `setenv`, then it is also set during the 'install'
  91. # phase, which inhibits unpacking the sdist, so the virtualenv isn't
  92. # useful for anything else without setting PYTHONPATH similarly.
  93. #
  94. # - `synapse` is also loaded from PYTHONPATH so even if you only set
  95. # PYTHONPATH for the test phase, we're still running the tests against
  96. # the working copy rather than the contents of the sdist. So frankly
  97. # you might as well use -e in the first place.
  98. #
  99. # )
  100. usedevelop=true
  101. # A test suite for the oldest supported versions of Python libraries, to catch
  102. # any uses of APIs not available in them.
  103. [testenv:py3-old]
  104. skip_install = true
  105. usedevelop = false
  106. deps =
  107. # Old automat version for Twisted
  108. Automat == 0.3.0
  109. lxml
  110. {[base]deps}
  111. commands =
  112. # Make all greater-thans equals so we test the oldest version of our direct
  113. # dependencies, but make the pyopenssl 17.0, which can work against an
  114. # OpenSSL 1.1 compiled cryptography (as older ones don't compile on Travis).
  115. /bin/sh -c 'python -m synapse.python_dependencies | sed -e "s/>=/==/g" -e "/psycopg2/d" -e "s/pyopenssl==16.0.0/pyopenssl==17.0.0/" | xargs -d"\n" pip install'
  116. # Install Synapse itself. This won't update any libraries.
  117. pip install -e ".[test]"
  118. {[testenv]commands}
  119. [testenv:benchmark]
  120. deps =
  121. {[base]deps}
  122. pyperf
  123. setenv =
  124. SYNAPSE_POSTGRES = 1
  125. commands =
  126. python -m synmark {posargs:}
  127. [testenv:packaging]
  128. skip_install = true
  129. usedevelop = false
  130. deps =
  131. check-manifest
  132. commands =
  133. check-manifest
  134. [testenv:check_codestyle]
  135. extras = lint
  136. commands =
  137. python -m black --check --diff {[base]lint_targets}
  138. flake8 {[base]lint_targets} {env:PEP8SUFFIX:}
  139. {toxinidir}/scripts-dev/config-lint.sh
  140. [testenv:check_isort]
  141. extras = lint
  142. commands = isort -c --df --sp setup.cfg {[base]lint_targets}
  143. [testenv:check-newsfragment]
  144. skip_install = true
  145. usedevelop = false
  146. deps = towncrier>=18.6.0rc1
  147. commands =
  148. python -m towncrier.check --compare-with=origin/develop
  149. [testenv:check-sampleconfig]
  150. commands = {toxinidir}/scripts-dev/generate_sample_config --check
  151. [testenv:combine]
  152. skip_install = true
  153. usedevelop = false
  154. deps =
  155. coverage
  156. pip>=10
  157. commands=
  158. coverage combine
  159. coverage report
  160. [testenv:cov-erase]
  161. skip_install = true
  162. usedevelop = false
  163. deps =
  164. coverage
  165. commands=
  166. coverage erase
  167. [testenv:cov-html]
  168. skip_install = true
  169. usedevelop = false
  170. deps =
  171. coverage
  172. commands=
  173. coverage html
  174. [testenv:mypy]
  175. deps =
  176. {[base]deps}
  177. extras = all,mypy
  178. commands = mypy