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
git:
depth: 25
quiet: true
python:
- 3.9
- 3.7
os:
- linux
matrix:
include:
- os: linux
name: PEP8 MyPy Coverage
python: 3.9
install: pip install .[tests,cov]
script:
- flake8
- mypy
after_success:
- 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. Tryautopep8 -i -r .
to quickly fix most minor issues. This setup assumes a file .flake8mypy
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:
stderr | outcome |
---|---|
== 0 | PASS |
!= 0 | FAIL |
A third case is an ERROR in setup, perhaps a prereq is missing from setup.cfg
.