Travis-CI Quick Start

Related: Travis-CI examples for several programming languages

This Travis-CI quick start assumes Python on GitHub for simplicity. See the Travis-CI examples for several other programming languages.

  1. have a minimal and setup.cfg
  2. Create free Travis-CI account using your Github credentials
  3. add the GitHub repository to Travis-CI
  4. create a .travis.yml like:
language: python
group: travis_latest

  depth: 25
  quiet: true

- 3.7
- 3.6
- 3.5

- linux

  - os: linux
    python: 3.7
    install: pip install -e .[tests,cov]
    - flake8
    - mypy . --ignore-missing-imports
    - pytest --cov
    - coveralls

install: pip install -e .[tests]

script: pytest -rsv

pytest --cov assumes coverage settings in .coveragerc.

Now, upon every git push, the Travis-CI dashboard will make the badge red/green depending on whether your test passed.

  • flake8 tests PEP8 compliance. Try autopep8 -i -r . to quickly fix most minor issues.
  • mypy tests static type hinting, which is a very good practice to reduce code errors.

Travis-CI output

The key point is that Travis CI considers only stderr == / != 0 for pass/fail:

== 0PASS
!= 0FAIL

A third case is an ERROR in setup, perhaps a prereq is missing from setup.cfg.

Code coverage

See my page.