[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
language: python
@ -8,23 +8,24 @@ cache: pip
before_install:
- lsb_release -a
- sudo add-apt-repository ppa:deluge-team/develop -y
- sudo apt-get update
- sudo add-apt-repository ppa:deluge-team/develop -yu
# command to install dependencies
install:
- bash -c "echo $APTPACKAGES"
- sudo apt-get install $APTPACKAGES
- pip install tox
- sudo apt install $APTPACKAGES
- pip install tox tox-venv
# 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
- tar -xvzf testssl.tar.gz
- mv -t deluge/tests/data testssl.sh-2.9.5-5/testssl.sh testssl.sh-2.9.5-5/etc/
- "if [ $TOX_ENV == 'security' ]; then
testssl_url=https://github.com/drwetter/testssl.sh/archive/v2.9.5-5.tar.gz;
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:
global:
- APTPACKAGES="python-libtorrent"
- APTPACKAGES_GTKUI="python-gobject python-glade2"
- APTPACKAGES_GTKUI="python-glade2"
- DISPLAY=:99.0
matrix:
@ -36,7 +37,7 @@ matrix:
#- env: TOX_ENV=flake8-complexity
- env: TOX_ENV=docs
#- 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=testcoverage APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI"
- env: TOX_ENV=plugins

View File

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

View File

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