tox.ini 5.7 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
  19. # we also need a semi-recent version of pip, because old ones fail to
  20. # install the "enum34" dependency of cryptography.
  21. pip>=10
  22. # directories/files we run the linters on
  23. lint_targets =
  24. setup.py
  25. synapse
  26. tests
  27. scripts
  28. scripts-dev
  29. stubs
  30. contrib
  31. synctl
  32. synmark
  33. .buildkite
  34. docker
  35. # default settings for all tox environments
  36. [testenv]
  37. deps =
  38. {[base]deps}
  39. extras =
  40. # install the optional dependendencies for tox environments without
  41. # '-noextras' in their name
  42. !noextras: all
  43. test
  44. setenv =
  45. # use a postgres db for tox environments with "-postgres" in the name
  46. # (see https://tox.readthedocs.io/en/3.20.1/config.html#factors-and-factor-conditional-settings)
  47. postgres: SYNAPSE_POSTGRES = 1
  48. # this is used by .coveragerc to refer to the top of our tree.
  49. TOP={toxinidir}
  50. passenv = *
  51. commands =
  52. # the "env" invocation enables coverage checking for sub-processes. This is
  53. # particularly important when running trial with `-j`, since that will make
  54. # it run tests in a subprocess, whose coverage would otherwise not be
  55. # tracked. (It also makes an explicit `coverage run` command redundant.)
  56. #
  57. # (See https://coverage.readthedocs.io/en/coverage-5.3/subprocess.html.
  58. # Note that the `coverage.process_startup()` call is done by
  59. # `coverage-enable-subprocess`.)
  60. #
  61. # we use "env" rather than putting a value in `setenv` so that it is not
  62. # inherited by other tox environments.
  63. #
  64. # keep this in sync with the copy in `testenv:py35-old`.
  65. #
  66. /usr/bin/env COVERAGE_PROCESS_START={toxinidir}/.coveragerc "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  67. # As of twisted 16.4, trial tries to import the tests as a package (previously
  68. # it loaded the files explicitly), which means they need to be on the
  69. # pythonpath. Our sdist doesn't include the 'tests' package, so normally it
  70. # doesn't work within the tox virtualenv.
  71. #
  72. # As a workaround, we tell tox to do install with 'pip -e', which just
  73. # creates a symlink to the project directory instead of unpacking the sdist.
  74. #
  75. # (An alternative to this would be to set PYTHONPATH to include the project
  76. # directory. Note two problems with this:
  77. #
  78. # - if you set it via `setenv`, then it is also set during the 'install'
  79. # phase, which inhibits unpacking the sdist, so the virtualenv isn't
  80. # useful for anything else without setting PYTHONPATH similarly.
  81. #
  82. # - `synapse` is also loaded from PYTHONPATH so even if you only set
  83. # PYTHONPATH for the test phase, we're still running the tests against
  84. # the working copy rather than the contents of the sdist. So frankly
  85. # you might as well use -e in the first place.
  86. #
  87. # )
  88. usedevelop=true
  89. # A test suite for the oldest supported versions of Python libraries, to catch
  90. # any uses of APIs not available in them.
  91. [testenv:py35-old]
  92. skip_install=True
  93. deps =
  94. # Ensure a version of setuptools that supports Python 3.5 is installed.
  95. setuptools < 51.0.0
  96. # Old automat version for Twisted
  97. Automat == 0.3.0
  98. lxml
  99. coverage
  100. coverage-enable-subprocess==1.0
  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. commands=
  148. coverage combine
  149. coverage report
  150. [testenv:cov-erase]
  151. skip_install = True
  152. deps =
  153. coverage
  154. commands=
  155. coverage erase
  156. [testenv:cov-html]
  157. skip_install = True
  158. deps =
  159. coverage
  160. commands=
  161. coverage html
  162. [testenv:mypy]
  163. deps =
  164. {[base]deps}
  165. extras = all,mypy
  166. commands = mypy