Travis-CI Quick Start

NOTE: many projects have transitioned to GitHub Actions due to Travis-CI build quotas for open source projects.

This Travis-CI quick start assumes Python on GitHub for simplicity. We assume the project has a minimal setup.cfg.

Create a .travis.yml like:

language: python
group: travis_latest

  depth: 25
  quiet: true

- 3.9
- 3.7

- linux

  - os: linux
    name: PEP8 MyPy Coverage
    python: 3.9
    install: pip install .[tests,cov]
    - flake8
    - mypy
    - pytest --cov
    - coveralls

install: pip install .[tests]

script: pytest

pytest --cov assumes code 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. This setup assumes a file .flake8
  • mypy checks static type annotation and assumes “files” is defined in .mypy.ini

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.