diff --git a/.travis.yml b/.travis.yml index 4328b5121..2c9ca9e88 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,23 @@ os: - linux - osx + +env: + global: + - PATH=/home/travis/bin:/home/travis/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + matrix: + - TESTENV=py35 + - TESTENV=py34 + - TESTENV=unittests-nodisp + - TESTENV=misc + - TESTENV=pep257 + - TESTENV=pyflakes + - TESTENV=pep8 + - TESTENV=mccabe + - TESTENV=pyroma + - TESTENV=check-manifest + - TESTENV=pylint + # Not really, but this is here so we can do stuff by hand. language: c @@ -13,22 +30,33 @@ cache: - $HOME/.cache/pip - $HOME/build/The-Compiler/qutebrowser/.cache -env: - - PATH=/home/travis/bin:/home/travis/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - - install: - python scripts/dev/ci_install.py script: - - '[[ $TRAVIS_OS_NAME == osx ]] && tox -e py35 || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && xvfb-run -s "-screen 0 640x480x16" tox -e py34 || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && tox -e unittests-nodisp || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && tox -e misc || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && tox -e pep257 || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && tox -e pyflakes || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && tox -e pep8 || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && tox -e mccabe || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && tox -e pyroma || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && tox -e check-manifest || true' - - '[[ $TRAVIS_OS_NAME == linux ]] && tox -e pylint || true' + - python scripts/dev/ci_run.py + +matrix: + exclude: + - os: linux + env: TESTENV=py35 + - os: osx + env: TESTENV=py34 + - os: osx + env: TESTENV=unittests-nodisp + - os: osx + env: TESTENV=misc + - os: osx + env: TESTENV=pep257 + - os: osx + env: TESTENV=pyflakes + - os: osx + env: TESTENV=pep8 + - os: osx + env: TESTENV=mccabe + - os: osx + env: TESTENV=pyroma + - os: osx + env: TESTENV=check-manifest + - os: osx + env: TESTENV=pylint diff --git a/scripts/dev/ci_install.py b/scripts/dev/ci_install.py index 5c7b5962a..e76f29233 100644 --- a/scripts/dev/ci_install.py +++ b/scripts/dev/ci_install.py @@ -38,6 +38,12 @@ try: except ImportError: winreg = None +TESTENV = os.environ['TESTENV'] +TRAVIS_OS = os.environ.get('TRAVIS_OS_NAME', None) +INSTALL_PYQT = TESTENV in ('py34', 'py35', 'unittests-nodisp', 'misc', + 'pylint') +XVFB = TRAVIS_OS == 'linux' and TESTENV == 'py34' + def apt_get(args): subprocess.check_call(['sudo', 'apt-get', '-y', '-q'] + args) @@ -52,9 +58,10 @@ def brew(args, silent=False): def check_setup(executable): - print("Checking setup...") - subprocess.check_call([executable, '-c', 'import PyQt5']) - subprocess.check_call([executable, '-c', 'import sip']) + if INSTALL_PYQT: + print("Checking setup...") + subprocess.check_call([executable, '-c', 'import PyQt5']) + subprocess.check_call([executable, '-c', 'import sip']) if 'APPVEYOR' in os.environ: @@ -80,21 +87,27 @@ if 'APPVEYOR' in os.environ: f.write(r'@C:\Python34\python %*') check_setup(r'C:\Python34\python') -elif os.environ.get('TRAVIS_OS_NAME', None) == 'linux': +elif TRAVIS_OS == 'linux': print("apt-get update...") apt_get(['update']) print("Installing packages...") - pkgs = ['python3-pyqt5', 'python3-pyqt5.qtwebkit', 'python-tox', - 'python3-dev', 'libpython3.4-dev', 'xvfb'] + pkgs = ['python-tox', 'python3-dev', 'libpython3.4-dev'] + if XVFB: + pkgs.append('xvfb') + if INSTALL_PYQT: + pkgs += ['python3-pyqt5', 'python3-pyqt5.qtwebkit'] apt_get(['install'] + pkgs) check_setup('python3') -elif os.environ.get('TRAVIS_OS_NAME', None) == 'osx': +elif TRAVIS_OS == 'osx': print("brew update...") brew(['update'], silent=True) print("Installing packages...") - brew(['install', 'python3', 'pyqt5']) + pkgs = ['python3'] + if INSTALL_PYQT: + pkgs.append('pyqt5') + brew(['install'] + pkgs) print("Installing tox...") subprocess.check_call(['sudo', 'pip3', 'install', 'tox']) diff --git a/scripts/dev/ci_run.py b/scripts/dev/ci_run.py new file mode 100644 index 000000000..1bd564900 --- /dev/null +++ b/scripts/dev/ci_run.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python2 +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2015 Florian Bruhin (The Compiler) + +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + +# pylint: skip-file + +"""Run tests on Travis CI based on environment variables. + +Note this file is written in python2 as this is more readily available on the +CI machines. +""" + +from __future__ import print_function + +import os +import sys +import subprocess + + +testenv = os.environ['TESTENV'] + + +if 'TRAVIS' not in os.environ: + def env(key): + return os.environ.get(key, None) + print("Unknown environment! (CI {}, APPVEYOR {}, TRAVIS {}, " + "TRAVIS_OS_NAME {})".format(env('CI'), env('APPVEYOR'), + env('TRAVIS'), env('TRAVIS_OS_NAME')), + file=sys.stderr) + sys.exit(1) + + +travis_os = os.environ['TRAVIS_OS_NAME'] + +if travis_os == 'linux' and testenv == 'py35': + raise Exception("Can't run py35 on Linux") +elif travis_os == 'osx' and testenv == 'py34': + raise Exception("Can't run py34 on OS X") + +if testenv == 'py34' and travis_os == 'linux': + subprocess.check_call(['xvfb-run', '-s', '-screen 0 640x480x16', + 'tox', '-e', testenv]) +else: + subprocess.check_call(['tox', '-e', testenv])