tox.ini 5.5 KB

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