tox.ini 5.7 KB

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