Blog Entry 9 years, 8 months ago

Integrate Travis CI, Coveralls.io into your Github repository

Each time having a push or pull request to your repository, it is great when having the product built, tested, and received final report automatically. Linking your Github repo to Travis CI, Coveralls.io greatly helps you doing that time-consuming and tedious work.

This entry assumes you already have general understandings about Travis CI (helps build and run tests) and Coveralls.io (tracking code coverages), if not you should go to travis-ci.com and coveralls.io first.

With Travis CI, you can link and make use of it on any public Github repos; with private ones, a paid package will be needed.

Here are the shorten guideline, hope it will be helpful:

1. In Github repo settings section, add Travis CI as new service.

2. Add .travis.yml into root directory of the repo.

Sample content:

language: python
python:
  - "2.6"
  - "2.7"
env:
  - DJANGO=1.4 DJANGO_VERSION_MIN=1.4 DJANGO_VERSION_MAX=1.5
  - DJANGO=1.6 DJANGO_VERSION_MIN=1.6 DJANGO_VERSION_MAX=1.7
  - DJANGO=1.7 DJANGO_VERSION_MIN=1.7 DJANGO_VERSION_MAX=1.8
matrix:
  exclude:
    - python: "2.6"
      env: DJANGO=1.7 DJANGO_VERSION_MIN=1.7 DJANGO_VERSION_MAX=1.8
install:
  - pip install -q "Django>=$DJANGO_VERSION_MIN,<$DJANGO_VERSION_MAX"
  - pip install -q django-nose==1.2 coverage coveralls flake8
  - pip install -e .
script:
  - flake8 scraper  --exclude=*/migrations/*,*test*
  - coverage run --source='./' --omit=*/migrations/*,*test* run_tests.py
after_script:
  - coveralls

This declares the main language for the target product, its versions, and preferred environments. Next sections are steps for installing, testing and submitting coverage result.

If the results of installing and testing sections are good, then you will receive blue 'passing' badges for the corresponding repository (from both Travis CI and Coveralls.io)

3. Embed the badges from Travis CI, Coveralls.io into the README file.

The most recent repo of mine (django-scraper) currently has these

Recent Reads