tox.ini 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. coverage-enable-subprocess
  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. setenv =
  23. PYTHONDONTWRITEBYTECODE = no_byte_code
  24. COVERAGE_PROCESS_START = {toxinidir}/.coveragerc
  25. [testenv]
  26. deps =
  27. {[base]deps}
  28. extras = all, test
  29. whitelist_externals =
  30. sh
  31. setenv =
  32. {[base]setenv}
  33. postgres: SYNAPSE_POSTGRES = 1
  34. TOP={toxinidir}
  35. passenv = *
  36. commands =
  37. /usr/bin/find "{toxinidir}" -name '*.pyc' -delete
  38. # Add this so that coverage will run on subprocesses
  39. {envbindir}/coverage run "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  40. # As of twisted 16.4, trial tries to import the tests as a package (previously
  41. # it loaded the files explicitly), which means they need to be on the
  42. # pythonpath. Our sdist doesn't include the 'tests' package, so normally it
  43. # doesn't work within the tox virtualenv.
  44. #
  45. # As a workaround, we tell tox to do install with 'pip -e', which just
  46. # creates a symlink to the project directory instead of unpacking the sdist.
  47. #
  48. # (An alternative to this would be to set PYTHONPATH to include the project
  49. # directory. Note two problems with this:
  50. #
  51. # - if you set it via `setenv`, then it is also set during the 'install'
  52. # phase, which inhibits unpacking the sdist, so the virtualenv isn't
  53. # useful for anything else without setting PYTHONPATH similarly.
  54. #
  55. # - `synapse` is also loaded from PYTHONPATH so even if you only set
  56. # PYTHONPATH for the test phase, we're still running the tests against
  57. # the working copy rather than the contents of the sdist. So frankly
  58. # you might as well use -e in the first place.
  59. #
  60. # )
  61. usedevelop=true
  62. # A test suite for the oldest supported versions of Python libraries, to catch
  63. # any uses of APIs not available in them.
  64. [testenv:py35-old]
  65. skip_install=True
  66. deps =
  67. # Old automat version for Twisted
  68. Automat == 0.3.0
  69. lxml
  70. coverage
  71. coverage-enable-subprocess
  72. commands =
  73. /usr/bin/find "{toxinidir}" -name '*.pyc' -delete
  74. # Make all greater-thans equals so we test the oldest version of our direct
  75. # dependencies, but make the pyopenssl 17.0, which can work against an
  76. # OpenSSL 1.1 compiled cryptography (as older ones don't compile on Travis).
  77. /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'
  78. # Install Synapse itself. This won't update any libraries.
  79. pip install -e ".[test]"
  80. {envbindir}/coverage run "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
  81. [testenv:benchmark]
  82. deps =
  83. {[base]deps}
  84. pyperf
  85. setenv =
  86. SYNAPSE_POSTGRES = 1
  87. commands =
  88. python -m synmark {posargs:}
  89. [testenv:packaging]
  90. skip_install=True
  91. deps =
  92. check-manifest
  93. commands =
  94. check-manifest
  95. [testenv:check_codestyle]
  96. extras = lint
  97. commands =
  98. python -m black --check --diff .
  99. /bin/sh -c "flake8 synapse tests scripts scripts-dev contrib synctl {env:PEP8SUFFIX:}"
  100. {toxinidir}/scripts-dev/config-lint.sh
  101. [testenv:check_isort]
  102. extras = lint
  103. commands = /bin/sh -c "isort -c --df --sp setup.cfg synapse tests scripts-dev scripts"
  104. [testenv:check-newsfragment]
  105. skip_install = True
  106. deps = towncrier>=18.6.0rc1
  107. commands =
  108. python -m towncrier.check --compare-with=origin/develop
  109. [testenv:check-sampleconfig]
  110. commands = {toxinidir}/scripts-dev/generate_sample_config --check
  111. [testenv:combine]
  112. skip_install = True
  113. deps =
  114. coverage
  115. commands=
  116. coverage combine
  117. coverage report
  118. [testenv:cov-erase]
  119. skip_install = True
  120. deps =
  121. coverage
  122. commands=
  123. coverage erase
  124. [testenv:cov-html]
  125. skip_install = True
  126. deps =
  127. coverage
  128. commands=
  129. coverage html
  130. [testenv:mypy]
  131. deps =
  132. {[base]deps}
  133. extras = all,mypy
  134. commands = mypy
  135. # To find all folders that pass mypy you run:
  136. #
  137. # find synapse/* -type d -not -name __pycache__ -exec bash -c "mypy '{}' > /dev/null" \; -print