1
0

tox.ini 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. [tox]
  2. envlist = packaging, py35, py36, py37, py38, py39, check_codestyle, check_isort
  3. [base]
  4. deps =
  5. python-subunit
  6. junitxml
  7. coverage
  8. # this is pinned since it's a bit of an obscure package.
  9. coverage-enable-subprocess==1.0
  10. # cyptography 2.2 requires setuptools >= 18.5
  11. #
  12. # older versions of virtualenv (?) give us a virtualenv with the same
  13. # version of setuptools as is installed on the system python (and tox runs
  14. # virtualenv under python3, so we get the version of setuptools that is
  15. # installed on that).
  16. #
  17. # anyway, make sure that we have a recent enough setuptools.
  18. setuptools>=18.5 ; python_version >= '3.6'
  19. setuptools>=18.5,<51.0.0 ; python_version < '3.6'
  20. # we also need a semi-recent version of pip, because old ones fail to
  21. # install the "enum34" dependency of cryptography.
  22. pip>=10 ; python_version >= '3.6'
  23. pip>=10,<21.0 ; python_version < '3.6'
  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. !noextras: all
  46. test
  47. setenv =
  48. # use a postgres db for tox environments with "-postgres" in the name
  49. # (see https://tox.readthedocs.io/en/3.20.1/config.html#factors-and-factor-conditional-settings)
  50. postgres: SYNAPSE_POSTGRES = 1
  51. # this is used by .coveragerc to refer to the top of our tree.
  52. TOP={toxinidir}
  53. passenv = *
  54. commands =
  55. # the "env" invocation enables coverage checking for sub-processes. This is
  56. # particularly important when running trial with `-j`, since that will make
  57. # it run tests in a subprocess, whose coverage would otherwise not be
  58. # tracked. (It also makes an explicit `coverage run` command redundant.)
  59. #
  60. # (See https://coverage.readthedocs.io/en/coverage-5.3/subprocess.html.
  61. # Note that the `coverage.process_startup()` call is done by
  62. # `coverage-enable-subprocess`.)
  63. #
  64. # we use "env" rather than putting a value in `setenv` so that it is not
  65. # inherited by other tox environments.
  66. #
  67. # keep this in sync with the copy in `testenv:py35-old`.
  68. #
  69. /usr/bin/env COVERAGE_PROCESS_START={toxinidir}/.coveragerc "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  70. # As of twisted 16.4, trial tries to import the tests as a package (previously
  71. # it loaded the files explicitly), which means they need to be on the
  72. # pythonpath. Our sdist doesn't include the 'tests' package, so normally it
  73. # doesn't work within the tox virtualenv.
  74. #
  75. # As a workaround, we tell tox to do install with 'pip -e', which just
  76. # creates a symlink to the project directory instead of unpacking the sdist.
  77. #
  78. # (An alternative to this would be to set PYTHONPATH to include the project
  79. # directory. Note two problems with this:
  80. #
  81. # - if you set it via `setenv`, then it is also set during the 'install'
  82. # phase, which inhibits unpacking the sdist, so the virtualenv isn't
  83. # useful for anything else without setting PYTHONPATH similarly.
  84. #
  85. # - `synapse` is also loaded from PYTHONPATH so even if you only set
  86. # PYTHONPATH for the test phase, we're still running the tests against
  87. # the working copy rather than the contents of the sdist. So frankly
  88. # you might as well use -e in the first place.
  89. #
  90. # )
  91. usedevelop=true
  92. # A test suite for the oldest supported versions of Python libraries, to catch
  93. # any uses of APIs not available in them.
  94. [testenv:py35-old]
  95. skip_install=True
  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. # we have to duplicate the command from `testenv` rather than refer to it
  109. # as `{[testenv]commands}`, because we run on ubuntu xenial, which has
  110. # tox 2.3.1, and https://github.com/tox-dev/tox/issues/208.
  111. #
  112. /usr/bin/env COVERAGE_PROCESS_START={toxinidir}/.coveragerc "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  113. [testenv:benchmark]
  114. deps =
  115. {[base]deps}
  116. pyperf
  117. setenv =
  118. SYNAPSE_POSTGRES = 1
  119. commands =
  120. python -m synmark {posargs:}
  121. [testenv:packaging]
  122. skip_install=True
  123. deps =
  124. check-manifest
  125. commands =
  126. check-manifest
  127. [testenv:check_codestyle]
  128. extras = lint
  129. commands =
  130. python -m black --check --diff {[base]lint_targets}
  131. flake8 {[base]lint_targets} {env:PEP8SUFFIX:}
  132. {toxinidir}/scripts-dev/config-lint.sh
  133. [testenv:check_isort]
  134. extras = lint
  135. commands = isort -c --df --sp setup.cfg {[base]lint_targets}
  136. [testenv:check-newsfragment]
  137. skip_install = True
  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. deps =
  146. coverage
  147. pip>=10 ; python_version >= '3.6'
  148. pip>=10,<21.0 ; python_version < '3.6'
  149. commands=
  150. coverage combine
  151. coverage report
  152. [testenv:cov-erase]
  153. skip_install = True
  154. deps =
  155. coverage
  156. commands=
  157. coverage erase
  158. [testenv:cov-html]
  159. skip_install = True
  160. deps =
  161. coverage
  162. commands=
  163. coverage html
  164. [testenv:mypy]
  165. deps =
  166. {[base]deps}
  167. extras = all,mypy
  168. commands = mypy