[Tests] Update tox and CI configs

- Add new requirements files to make it easier to install deps.

- Tox changes
  - Update tox to use new requirements files.
  - Tweak heading styles.
  - Add development environment command `devenv`.
  - Remove testenv command as it would run on devenv creation.

- Travis changes
  - Now uses xenial as trusty is very old now.
  - Trial run disabled to speed up tests.
  - Add tox-venv for Python 3 support.
  - Only install testssl if running security tests.

- Appveyor
  - Add tox-venv for Python 3 support.
  - Use requirements file for non-tox.
  - Remove trial run to speed up testing.
This commit is contained in:
Calum Lind 2018-10-03 16:12:29 +01:00
parent 0548bdb655
commit 6973f96f8c
7 changed files with 82 additions and 50 deletions

View File

@ -1,4 +1,4 @@
dist: trusty dist: xenial
sudo: required sudo: required
language: python language: python
@ -8,23 +8,24 @@ cache: pip
before_install: before_install:
- lsb_release -a - lsb_release -a
- sudo add-apt-repository ppa:deluge-team/develop -y - sudo add-apt-repository ppa:deluge-team/develop -yu
- sudo apt-get update
# command to install dependencies # command to install dependencies
install: install:
- bash -c "echo $APTPACKAGES" - bash -c "echo $APTPACKAGES"
- sudo apt-get install $APTPACKAGES - sudo apt install $APTPACKAGES
- pip install tox - pip install tox tox-venv
# the next part is for the security tests only. # the next part is for the security tests only.
- wget https://github.com/drwetter/testssl.sh/archive/v2.9.5-5.tar.gz -O testssl.tar.gz - "if [ $TOX_ENV == 'security' ]; then
- tar -xvzf testssl.tar.gz testssl_url=https://github.com/drwetter/testssl.sh/archive/v2.9.5-5.tar.gz;
- mv -t deluge/tests/data testssl.sh-2.9.5-5/testssl.sh testssl.sh-2.9.5-5/etc/ wget -O- $testssl_url | tar xz
&& mv -t deluge/tests/data testssl.sh-2.9.5-5/testssl.sh testssl.sh-2.9.5-5/etc/;
fi"
env: env:
global: global:
- APTPACKAGES="python-libtorrent" - APTPACKAGES="python-libtorrent"
- APTPACKAGES_GTKUI="python-gobject python-glade2" - APTPACKAGES_GTKUI="python-glade2"
- DISPLAY=:99.0 - DISPLAY=:99.0
matrix: matrix:
@ -36,7 +37,7 @@ matrix:
#- env: TOX_ENV=flake8-complexity #- env: TOX_ENV=flake8-complexity
- env: TOX_ENV=docs - env: TOX_ENV=docs
#- env: TOX_ENV=todo #- env: TOX_ENV=todo
- env: TOX_ENV=trial APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI" #- env: TOX_ENV=trial APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI"
- env: TOX_ENV=pygtkui APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI" - env: TOX_ENV=pygtkui APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI"
#- env: TOX_ENV=testcoverage APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI" #- env: TOX_ENV=testcoverage APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI"
- env: TOX_ENV=plugins - env: TOX_ENV=plugins

View File

@ -4,9 +4,7 @@ environment:
APPVEYOR_SAVE_CACHE_ON_ERROR: true APPVEYOR_SAVE_CACHE_ON_ERROR: true
matrix: matrix:
# See: http://www.appveyor.com/docs/installed-software#python
- TOXENV: flake8 - TOXENV: flake8
- TOXENV: trial
- TOXENV: pydef - TOXENV: pydef
- TOXENV: pygtkui - TOXENV: pygtkui
- TOXENV: plugins - TOXENV: plugins
@ -30,23 +28,12 @@ install:
- "python -m pip install --upgrade pip" - "python -m pip install --upgrade pip"
- if defined TOXENV ( - if defined TOXENV (
pip install pip install tox tox_venv
tox
pywin32
certifi
) )
- if not defined TOXENV ( - if not defined TOXENV (
pip install pip install
-rrequirements.txt
slimit slimit
twisted[tls]
chardet
mako
pyxdg
pillow
slimit
setproctitle
pywin32
certifi
pygame pygame
bbfreeze bbfreeze
pefile pefile

View File

@ -2,6 +2,7 @@
requires = [ requires = [
"setuptools", "setuptools",
"wheel", "wheel",
"slimit",
] ]
[tool.black] [tool.black]

16
requirements-dev.txt Normal file
View File

@ -0,0 +1,16 @@
-r requirements.txt
-r requirements-docs.txt
-r requirements-tests.txt
sphinx-autobuild
tox
tox-venv
detox
pre-commit
pre-commit-hooks
flake8-blind-except
flake8-builtins
flake8-commas
flake8-comprehensions
flake8-debugger
flake8-mock
flake8-mutable

10
requirements-tests.txt Normal file
View File

@ -0,0 +1,10 @@
pytest
pytest-twisted
pytest-cov
mock
flake8
flake8-quotes
flake8-isort
pep8-naming
mccabe
pylint

12
requirements.txt Normal file
View File

@ -0,0 +1,12 @@
twisted[tls]>=16.6
pyopenssl
pyxdg
pillow
mako
chardet
six
setproctitle
pywin32; sys.platform == 'win32'
py2-ipaddress; sys.platform == 'win32'
certifi; sys.platform == 'win32'
zope-interface

55
tox.ini
View File

@ -7,33 +7,28 @@
envlist = py27, flake8, docs envlist = py27, flake8, docs
minversion=2.0 minversion=2.0
[base]
deps = -rrequirements.txt
[testenv] [testenv]
install_command = pip install --ignore-installed {opts} {packages} install_command = pip install --ignore-installed {opts} {packages}
passenv = DISPLAY PYTHONPATH passenv = DISPLAY PYTHONPATH
setenv = PYTHONPATH = {toxinidir} setenv = PYTHONPATH = {toxinidir}
sitepackages = True sitepackages = True
deps = deps =
twisted[tls] {[base]deps}
service_identity -rrequirements-tests.txt
mako
chardet
pyopenssl
pyxdg
pytest
pytest-twisted
mock
slimit slimit
pillow whitelist_externals = pytest
whitelist_externals = pytest bash
commands = {envpython} setup.py test
[pytest] [pytest]
# Hide logged warnings and errors in test output. # Hide logged warnings and errors in test output.
log_cli_level = CRITICAL log_cli_level = CRITICAL
##############
# ==========
# Unit tests # Unit tests
############## # ==========
[testenv:pydef] [testenv:pydef]
commands = commands =
@ -72,7 +67,6 @@ commands =
[testenv:py27] [testenv:py27]
deps = deps =
{[testenv]deps} {[testenv]deps}
py2-ipaddress
basepython = python2.7 basepython = python2.7
commands = {[testenv:pydef]commands} commands = {[testenv:pydef]commands}
@ -80,12 +74,14 @@ commands = {[testenv:pydef]commands}
basepython = python3 basepython = python3
commands = {[testenv:pydef]commands} commands = {[testenv:pydef]commands}
###########################
# Code style verification # =======================
########################### # Code linting
# =======================
[testenv:flake8] [testenv:flake8]
# Disable site packages to avoid using system flake8 which uses hardcoded python path which imports the wrong libraries. # Disable site packages to avoid using system flake8 which uses
# hardcoded python path which imports the wrong libraries.
sitepackages = False sitepackages = False
deps = deps =
{[testenv]deps} {[testenv]deps}
@ -121,9 +117,9 @@ commands =
python -m pylint deluge/plugins/*/deluge/ python -m pylint deluge/plugins/*/deluge/
###################### # =============
# Unit Test coverage # Test coverage
###################### # =============
[testcoveragebase] [testcoveragebase]
deps = deps =
@ -152,9 +148,9 @@ commands =
coverage html -d docs/build/htmlcoverage coverage html -d docs/build/htmlcoverage
###################### # ===================
# Docs generation # Documentation build
###################### # ===================
# We do not have all dependencies on RTD and travis so we exclude the # We do not have all dependencies on RTD and travis so we exclude the
# site packages (sitepackages=False) when building docs so that local # site packages (sitepackages=False) when building docs so that local
@ -188,3 +184,12 @@ commands =
mkdir -p build/doccoverage mkdir -p build/doccoverage
sphinx-build -W -b coverage -d build/doctrees source build/doccoverage sphinx-build -W -b coverage -d build/doctrees source build/doccoverage
pytest --doctest-glob='*.rst' pytest --doctest-glob='*.rst'
# ========================
# Developement Environment
# ========================
[testenv:devenv]
envdir = .venv
usedevelop = True
deps = -rrequirements-dev.txt