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.
 
 
 
 
 
 

209 lines
6.0 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. {[base]deps}
  114. commands =
  115. # Make all greater-thans equals so we test the oldest version of our direct
  116. # dependencies, but make the pyopenssl 17.0, which can work against an
  117. # OpenSSL 1.1 compiled cryptography (as older ones don't compile on Travis).
  118. /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'
  119. # Install Synapse itself. This won't update any libraries.
  120. pip install -e ".[test]"
  121. {[testenv]commands}
  122. [testenv:benchmark]
  123. deps =
  124. {[base]deps}
  125. pyperf
  126. setenv =
  127. SYNAPSE_POSTGRES = 1
  128. commands =
  129. python -m synmark {posargs:}
  130. [testenv:packaging]
  131. skip_install = true
  132. usedevelop = false
  133. deps =
  134. check-manifest
  135. commands =
  136. check-manifest
  137. [testenv:check_codestyle]
  138. extras = lint
  139. commands =
  140. python -m black --check --diff {[base]lint_targets}
  141. flake8 {[base]lint_targets} {env:PEP8SUFFIX:}
  142. {toxinidir}/scripts-dev/config-lint.sh
  143. [testenv:check_isort]
  144. extras = lint
  145. commands = isort -c --df --sp setup.cfg {[base]lint_targets}
  146. [testenv:check-newsfragment]
  147. skip_install = true
  148. usedevelop = false
  149. deps = towncrier>=18.6.0rc1
  150. commands =
  151. python -m towncrier.check --compare-with=origin/develop
  152. [testenv:check-sampleconfig]
  153. commands = {toxinidir}/scripts-dev/generate_sample_config --check
  154. [testenv:combine]
  155. skip_install = true
  156. usedevelop = false
  157. deps =
  158. coverage
  159. pip>=10
  160. commands=
  161. coverage combine
  162. coverage report
  163. [testenv:cov-erase]
  164. skip_install = true
  165. usedevelop = false
  166. deps =
  167. coverage
  168. commands=
  169. coverage erase
  170. [testenv:cov-html]
  171. skip_install = true
  172. usedevelop = false
  173. deps =
  174. coverage
  175. commands=
  176. coverage html
  177. [testenv:mypy]
  178. deps =
  179. {[base]deps}
  180. extras = all,mypy
  181. commands = mypy