tox.ini 4.2 KB

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