tox.ini 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. [tox]
  2. envlist = packaging, py35, py36, py37, py38, py39, check_codestyle, check_isort
  3. [base]
  4. extras = test
  5. deps =
  6. python-subunit
  7. junitxml
  8. coverage
  9. # this is pinned since it's a bit of an obscure package.
  10. coverage-enable-subprocess==1.0
  11. # cyptography 2.2 requires setuptools >= 18.5
  12. #
  13. # older versions of virtualenv (?) give us a virtualenv with the same
  14. # version of setuptools as is installed on the system python (and tox runs
  15. # virtualenv under python3, so we get the version of setuptools that is
  16. # installed on that).
  17. #
  18. # anyway, make sure that we have a recent enough setuptools.
  19. setuptools>=18.5
  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
  23. [testenv]
  24. deps =
  25. {[base]deps}
  26. extras = all, test
  27. setenv =
  28. # use a postgres db for tox environments with "-postgres" in the name
  29. # (see https://tox.readthedocs.io/en/3.20.1/config.html#factors-and-factor-conditional-settings)
  30. postgres: SYNAPSE_POSTGRES = 1
  31. # this is used by .coveragerc to refer to the top of our tree.
  32. TOP={toxinidir}
  33. passenv = *
  34. commands =
  35. # the "env" invocation enables coverage checking for sub-processes. This is
  36. # particularly important when running trial with `-j`, since that will make
  37. # it run tests in a subprocess, whose coverage would otherwise not be
  38. # tracked. (It also makes an explicit `coverage run` command redundant.)
  39. #
  40. # (See https://coverage.readthedocs.io/en/coverage-5.3/subprocess.html.
  41. # Note that the `coverage.process_startup()` call is done by
  42. # `coverage-enable-subprocess`.)
  43. #
  44. # we use "env" rather than putting a value in `setenv` so that it is not
  45. # inherited by other tox environments.
  46. #
  47. # keep this in sync with the copy in `testenv:py35-old`.
  48. #
  49. /usr/bin/env COVERAGE_PROCESS_START={toxinidir}/.coveragerc "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  50. # As of twisted 16.4, trial tries to import the tests as a package (previously
  51. # it loaded the files explicitly), which means they need to be on the
  52. # pythonpath. Our sdist doesn't include the 'tests' package, so normally it
  53. # doesn't work within the tox virtualenv.
  54. #
  55. # As a workaround, we tell tox to do install with 'pip -e', which just
  56. # creates a symlink to the project directory instead of unpacking the sdist.
  57. #
  58. # (An alternative to this would be to set PYTHONPATH to include the project
  59. # directory. Note two problems with this:
  60. #
  61. # - if you set it via `setenv`, then it is also set during the 'install'
  62. # phase, which inhibits unpacking the sdist, so the virtualenv isn't
  63. # useful for anything else without setting PYTHONPATH similarly.
  64. #
  65. # - `synapse` is also loaded from PYTHONPATH so even if you only set
  66. # PYTHONPATH for the test phase, we're still running the tests against
  67. # the working copy rather than the contents of the sdist. So frankly
  68. # you might as well use -e in the first place.
  69. #
  70. # )
  71. usedevelop=true
  72. # A test suite for the oldest supported versions of Python libraries, to catch
  73. # any uses of APIs not available in them.
  74. [testenv:py35-old]
  75. skip_install=True
  76. deps =
  77. # Old automat version for Twisted
  78. Automat == 0.3.0
  79. lxml
  80. coverage
  81. coverage-enable-subprocess==1.0
  82. commands =
  83. # Make all greater-thans equals so we test the oldest version of our direct
  84. # dependencies, but make the pyopenssl 17.0, which can work against an
  85. # OpenSSL 1.1 compiled cryptography (as older ones don't compile on Travis).
  86. /bin/sh -c 'python -m synapse.python_dependencies | sed -e "s/>=/==/g" -e "s/psycopg2==2.6//" -e "s/pyopenssl==16.0.0/pyopenssl==17.0.0/" | xargs -d"\n" pip install'
  87. # Install Synapse itself. This won't update any libraries.
  88. pip install -e ".[test]"
  89. # we have to duplicate the command from `testenv` rather than refer to it
  90. # as `{[testenv]commands}`, because we run on ubuntu xenial, which has
  91. # tox 2.3.1, and https://github.com/tox-dev/tox/issues/208.
  92. #
  93. /usr/bin/env COVERAGE_PROCESS_START={toxinidir}/.coveragerc "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  94. [testenv:benchmark]
  95. deps =
  96. {[base]deps}
  97. pyperf
  98. setenv =
  99. SYNAPSE_POSTGRES = 1
  100. commands =
  101. python -m synmark {posargs:}
  102. [testenv:packaging]
  103. skip_install=True
  104. deps =
  105. check-manifest
  106. commands =
  107. check-manifest
  108. [testenv:check_codestyle]
  109. extras = lint
  110. commands =
  111. python -m black --check --diff .
  112. /bin/sh -c "flake8 synapse tests scripts scripts-dev contrib synctl {env:PEP8SUFFIX:}"
  113. {toxinidir}/scripts-dev/config-lint.sh
  114. [testenv:check_isort]
  115. extras = lint
  116. commands = /bin/sh -c "isort -c --df --sp setup.cfg synapse tests scripts-dev scripts"
  117. [testenv:check-newsfragment]
  118. skip_install = True
  119. deps = towncrier>=18.6.0rc1
  120. commands =
  121. python -m towncrier.check --compare-with=origin/develop
  122. [testenv:check-sampleconfig]
  123. commands = {toxinidir}/scripts-dev/generate_sample_config --check
  124. [testenv:combine]
  125. skip_install = True
  126. deps =
  127. coverage
  128. commands=
  129. coverage combine
  130. coverage report
  131. [testenv:cov-erase]
  132. skip_install = True
  133. deps =
  134. coverage
  135. commands=
  136. coverage erase
  137. [testenv:cov-html]
  138. skip_install = True
  139. deps =
  140. coverage
  141. commands=
  142. coverage html
  143. [testenv:mypy]
  144. deps =
  145. {[base]deps}
  146. extras = all,mypy
  147. commands = mypy