tox.ini 4.5 KB

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