You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

212 lines
6.2 KiB

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