From 2d9907289d2497255896cd545f6bfeeb8124ae94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malthe=20J=C3=B8rgensen?= Date: Thu, 24 Sep 2015 15:04:51 +0200 Subject: [PATCH] [Tests] Add Travis CI + Coveralls.io code coverage Adds the files `.travis.yml` and `.coveragerc` enabling testing on Travis CI and code coverage statistics on Coveralls.io, similar to the parent MongoEngine repo (https://github.com/MongoEngine/mongoengine). Should fix issue #4. (Somebody may have to login to travis-ci.org to get things going) --- .coveragerc | 9 +++++++ .gitignore | 4 ++++ .travis.yml | 48 +++++++++++++++++++++++++++++++++++++ requirements-python<3.4.txt | 1 + 4 files changed, 62 insertions(+) create mode 100644 .coveragerc create mode 100644 .travis.yml create mode 100644 requirements-python<3.4.txt diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..03f5bf1 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,9 @@ +# Test coverage configuration. +# Usage: +# pip install coverage +# coverage erase # clears previous data if any +# coverage run -m unittest2 +# coverage html # creates ./htmlcov/*.html (check index.html) +[run] +branch = true +source = extras_mongoengine diff --git a/.gitignore b/.gitignore index 1bbfde7..afa178a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ *.pyc build/ venv/ + +# Coverage +/htmlcov +/.coverage diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a8a32fe --- /dev/null +++ b/.travis.yml @@ -0,0 +1,48 @@ +language: python +python: +- '2.6' +- '2.7' +- '3.2' +- '3.3' +- '3.4' +- pypy +- pypy3 +env: +- PYMONGO=2.7 +- PYMONGO=2.8 +- PYMONGO=3.0 +- PYMONGO=dev +matrix: + fast_finish: true +before_install: +# Install MongoDB +- travis_retry sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 +- echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | + sudo tee /etc/apt/sources.list.d/mongodb.list +- travis_retry sudo apt-get update +- travis_retry sudo apt-get install mongodb-org-server +install: +# 1. Install Python +- sudo apt-get install python-dev python3-dev +# 2. Install general requirements (Python packages) +- pip install -r requirements.txt +# 3. Enums in Python only became available in 3.4. +# The package `enum34` listed in `requirements-python<3.4.txt` is a backport. +- if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install -r 'requirements-python<3.4.txt'; fi +- if [[ $TRAVIS_PYTHON_VERSION == 3.2* ]]; then pip install -r 'requirements-python<3.4.txt'; fi +- if [[ $TRAVIS_PYTHON_VERSION == 3.3* ]]; then pip install -r 'requirements-python<3.4.txt'; fi +- if [[ $TRAVIS_PYTHON_VERSION == pypy* ]]; then pip install -r 'requirements-python<3.4.txt'; fi +# Coverage 4.0 doesn't support Python 3.2. Install an older version +# before coveralls tries to install the latest. (pypy3 is really Python 3.2) +- if [[ $TRAVIS_PYTHON_VERSION == '3.2' ]]; then travis_retry pip install 'coverage<4.0'; fi +- if [[ $TRAVIS_PYTHON_VERSION == 'pypy3' ]]; then travis_retry pip install 'coverage<4.0'; fi +- travis_retry pip install tox>=1.9 coveralls +#- travis_retry tox -e $(echo py$TRAVIS_PYTHON_VERSION-mg$PYMONGO | tr -d . | sed -e 's/pypypy/pypy/') -- -e test +script: +#- tox -e $(echo py$TRAVIS_PYTHON_VERSION-mg$PYMONGO | tr -d . | sed -e 's/pypypy/pypy/') -- --with-coverage +# Run tests with coverage (similar to `python -m unittest2` +# or `unit2` on Python 2.6. +- coverage run -m unittest2 +after_script: +# Submit coverage to coverall.io +- coveralls --verbose diff --git a/requirements-python<3.4.txt b/requirements-python<3.4.txt new file mode 100644 index 0000000..dc3292c --- /dev/null +++ b/requirements-python<3.4.txt @@ -0,0 +1 @@ +enum34