Integrating coveralls with travis in a python project

- 1 min

This post is about setting up coveralls and travis in a Python project.

Greb is a dictionary cli, written in Python which uses Travis to check whether the test cases are running fine or not. Travis as the wiki says is a continuous integration service which is used to build and test software projects hosted on Github.

Config for travis lives in a file called .travis.yml which should be present at the root directory of the project. When any commit is pushed or a pull request is created, a webhook is triggered, which initiates the travis and it then checks the build process.

Initially, greb had only a travis integration, which looked something like

language: python
python:
    - "3.4"
    - "3.3"
    - "2.7"
install:
    - "pip install ."
    - "pip install flake8"
    - "pip install ."
script:
    - "python -m test.test_greb"
    - "flake8 greb"
    - "flake8 test"

The file is self-explanatory, except the script part. Here I am using unit testing hence the line python -m test.test_greb

Now I wanted to integrate coveralls.io in greb. The integration is very simple. Here are the steps

The updated .travis.yml will look something like

language: python
python:
    - "3.4"
    - "3.3"
    - "2.7"
install:
    - "pip install ."
    - "pip install flake8"
    - "pip install coveralls"
script:
    - "flake8 greb"
    - "flake8 test"
    - "coverage run --source=greb -m test.test_greb"
after_script:
    - coveralls

References

Taranjeet Singh

Taranjeet Singh

Full Stack Developer, Entrepreneur

comments powered by Disqus
rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora