From 0b2cb7539ff5b321fe285f47c9b7617653471d7a Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Wed, 10 Oct 2018 14:49:39 +0100 Subject: [PATCH] Cleanup Tox and CI configs - Use the apt addon for installing libtorrent package. - Start the py3 test sooner as it is slow to complete. - Add if conditions for gtkui test dependencies. - Remove Appveyor tests that are taken care of by Travis. --- .travis.yml | 83 ++++++++++++++++++++++++++-------------------------- appveyor.yml | 4 +-- tox.ini | 47 ++++++++++------------------- 3 files changed, 57 insertions(+), 77 deletions(-) diff --git a/.travis.yml b/.travis.yml index 677b78950..e18bb59e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,69 +3,68 @@ sudo: required language: python python: - - "2.7" + - 2.7 cache: pip - -before_install: - - lsb_release -a - - sudo add-apt-repository ppa:deluge-team/develop -yu - -addons: - apt: - sources: - - deadsnakes - packages: - # Need Py 3.6 specifically for pre-commit to run black formatter. - - python3.6 - # To provide ensurepip module. - - python3-venv - -# command to install dependencies -install: - - bash -c "echo $APTPACKAGES" - - sudo apt install $APTPACKAGES - - pip install tox tox-venv - # the next part is for the security tests only. - - "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" +virtualenv: + system_site_packages: true env: global: - - APTPACKAGES="python-libtorrent python3-libtorrent" - - APTPACKAGES_GTKUI="python-glade2" - DISPLAY=:99.0 matrix: include: - - name: Unit tests - env: TOX_ENV=pydef + - name: Unit tests - Python 2 + env: TOX_ENV=py27 + - name: Unit tests - Python 3 + python: 3.5 + env: TOX_ENV=py3 - if: commit_message =~ SECURITY_TEST env: TOX_ENV=security - name: Code linting env: TOX_ENV=lint - name: Docs build env: TOX_ENV=docs - - name: PyGTK unit tests only - env: TOX_ENV=pygtkui APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI" + - name: PyGTK unit tests + env: TOX_ENV=pygtkui - name: Plugins unit tests env: TOX_ENV=plugins - - name: Python 3 unit tests - python: 3.5 - env: TOX_ENV=py3 -virtualenv: - system_site_packages: true +addons: + apt: + sources: + - sourceline: "ppa:deluge-team/develop" + - deadsnakes + packages: + - python-libtorrent + - python3-libtorrent + # Install py36 specifically for pre-commit to run black formatter. + - python3.6 + # Intall python3-venv to provide ensurepip module for tox. + - python3-venv + +# Install dependencies +install: + - pip install tox tox-venv + - "if [ $TOX_ENV == 'pygtkui' ]; then + sudo apt install python-glade2; + fi" + - "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" -# We use xvfb for the GTKUI tests before_script: - export PYTHONPATH=$PYTHONPATH:$PWD - python -c "import libtorrent as lt; print(lt.__version__)" - - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16" - - echo '2.0.0.dev0' > RELEASE-VERSION + # Start xvfb for the GTKUI tests + - "if [ $TOX_ENV == 'pygtkui' ]; then + /sbin/start-stop-daemon --start --quiet --background \ + --make-pidfile --pidfile /tmp/custom_xvfb_99.pid \ + --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16; + fi" + - echo "2.0.0.dev0" > RELEASE-VERSION script: - - bash -c "echo $DISPLAY" - tox -e $TOX_ENV diff --git a/appveyor.yml b/appveyor.yml index 100463b98..e307283dd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,10 +4,8 @@ environment: APPVEYOR_SAVE_CACHE_ON_ERROR: true matrix: - - TOXENV: pydef + - TOXENV: py27 - TOXENV: pygtkui - - TOXENV: plugins - - TOXENV: docs - PYTHON_VERSION: "2.7.x" pull_requests: diff --git a/tox.ini b/tox.ini index f60321311..564b33679 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # Usage: `pip install tox` and then run `tox` from this directory. [tox] -envlist = py27, lint, docs +envlist = py27, py3, lint, docs minversion=2.0 [base] @@ -22,58 +22,46 @@ sitepackages = True deps = {[base]deps} -rrequirements-tests.txt -whitelist_externals = pytest +commands = + python -c "import libtorrent as lt; print(lt.__version__)" + pytest -v -s -m "not (todo or gtkui or security)" deluge/tests [pytest] # Hide logged warnings and errors in test output. log_cli_level = CRITICAL -addopts = -p no:warnings +addopts = -p no:warnings --basetemp=_pytest_temp # ========== # Unit tests # ========== -[testenv:pydef] -commands = - python -c "import libtorrent as lt; print(lt.__version__)" - pytest -v --basetemp=_pytest_temp -s -m "not (todo or gtkui or security)" deluge/tests - [testenv:security] setenv = SECURITY_TESTS = True -commands = pytest -v --basetemp=_pytest_temp -s -m "security" deluge/tests/ +commands = pytest -v -s -m "security" deluge/tests/ [testenv:pygtkui] -commands = pytest -v --basetemp=_pytest_temp -s -m "gtkui" deluge/tests +commands = pytest -v -s -m "gtkui" deluge/tests [testenv:todo] -commands = pytest -v --basetemp=_pytest_temp -s -m "todo" deluge/tests +commands = pytest -v -s -m "todo" deluge/tests [testenv:trial] setenv = {[testenv]setenv}{:}{toxinidir}/deluge/tests commands = - python -c "import libtorrent as lt; print lt.__version__" + python -c "import libtorrent as lt; print(lt.__version__)" python -m twisted.trial --reporter=deluge-reporter deluge.tests [testenv:plugins] setenv = PYTHONPATH = {toxinidir}{:}{toxinidir}/deluge/plugins -whitelist_externals = bash commands = python setup.py build_plugins --develop --install-dir={toxinidir}/deluge/plugins/ - pytest -v --basetemp=_pytest_temp -s -m "not gtkui" deluge/plugins + pytest -v -s -m "not gtkui" deluge/plugins [testenv:pluginsgtkui] setenv = PYTHONPATH = {toxinidir}{:}{toxinidir}/deluge/plugins commands = python setup.py build_plugins --develop --install-dir={toxinidir}/deluge/plugins/ - pytest -v --basetemp=_pytest_temp -s deluge/plugins - -[testenv:py27] -basepython = python2.7 -commands = {[testenv:pydef]commands} - -[testenv:py3] -basepython = python3 -commands = {[testenv:pydef]commands} + pytest -v -s deluge/plugins # ======================= @@ -134,15 +122,11 @@ deps = {[testenv]deps} pytest-cov coverage -whitelist_externals = - {[testenv]whitelist_externals} - coverage commands = coverage run --branch --source=deluge -m pytest -m "not todo" deluge/tests/ [testenv:testcoverage] setenv = {[testenv]setenv} deps = {[testcoveragebase]deps} -whitelist_externals = {[testcoveragebase]whitelist_externals} commands = {[testcoveragebase]commands} coverage report @@ -150,7 +134,6 @@ commands = [testenv:testcoverage-html] setenv = {[testenv]setenv} deps = {[testcoveragebase]deps} -whitelist_externals = {[testcoveragebase]whitelist_externals} commands = {[testcoveragebase]commands} coverage html -d docs/build/htmlcoverage @@ -184,9 +167,7 @@ changedir = {[docsbase]changedir} deps = {[docsbase]deps} pytest-cov -whitelist_externals = - pytest - mkdir +whitelist_externals = mkdir commands = mkdir -p build/doccoverage sphinx-build -W -b coverage -d build/doctrees source build/doccoverage @@ -201,13 +182,15 @@ usedevelop = True deps = -rrequirements-dev.txt [testenv:denv2] -envdir = .venv2 basepython = python2.7 +envdir = .venv2 usedevelop = {[basedev]usedevelop} deps = {[basedev]deps} +commands = [testenv:denv3] basepython = python3 envdir = .venv3 usedevelop = {[basedev]usedevelop} deps = {[basedev]deps} +commands =