You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

169 lines
4.7 KiB

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