Skip to content

Commit

Permalink
[Tests] Add Travis CI + Coveralls.io code coverage
Browse files Browse the repository at this point in the history
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 MongoEngine#4.
(Somebody may have to login to travis-ci.org to get things going)
  • Loading branch information
malthejorgensen committed Oct 12, 2015
1 parent e46de91 commit 2d99072
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
*.pyc
build/
venv/

# Coverage
/htmlcov
/.coverage
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions requirements-python<3.4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enum34

0 comments on commit 2d99072

Please sign in to comment.