tox.ini 5.2 KB

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