Skip to content

Commit af728d9

Browse files
committed
[coverage] Add coverage with coveralls 👖
There are other services to get the code coverage, this commit implements it with `coveralls` because is the one that uses the main project `kivy` Also: - add coverage badge to README.md file - add file `.coveragerc` to configure the behaviour of our coverage
1 parent ff42ca5 commit af728d9

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

.coveragerc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[run]
2+
omit =
3+
*test*
4+
5+
[report]
6+
exclude_lines =
7+
pragma: no cover
8+
def __repr__
9+
raise NotImplementedError
10+
if __name__ == .__main__.:

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ services:
99

1010
before_install:
1111
- travis_retry sudo apt update -qq
12-
- travis_retry sudo apt install -qq --no-install-recommends python2.7 python3 python3-venv python3-virtualenv
12+
# to successfully send the coveralls reports we need pyOpenSSL
13+
- travis_retry sudo apt install -qq --no-install-recommends python2.7 python3 python3-venv python3-virtualenv python3-setuptools python3-pip python3-openssl
1314
# (venv/virtualenv are both used by tests/test_pythonpackage.py)
1415
- sudo pip install tox>=2.0
16+
- sudo pip3 install coveralls
1517
# https://github.com/travis-ci/travis-ci/issues/6069#issuecomment-266546552
1618
- git remote set-branches --add origin master
1719
- git fetch
@@ -39,6 +41,8 @@ script:
3941
# case that the travis log doesn't produce any output for more than 10 minutes
4042
- while sleep 540; do echo "==== Still running (travis, don't kill me) ===="; done &
4143
- docker build --tag=p4a --file Dockerfile.py3 .
42-
- docker run -e CI p4a /bin/sh -c "$COMMAND"
44+
- docker run -e CI -e TRAVIS_JOB_ID="$TRAVIS_JOB_ID" -e TRAVIS_BRANCH="$TRAVIS_BRANCH" p4a /bin/sh -c "$COMMAND"
4345
# kill the background process started before run docker
4446
- kill %1
47+
after_success:
48+
- coveralls

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ python-for-android
22
==================
33

44
[![Build Status](https://travis-ci.org/kivy/python-for-android.svg?branch=master)](https://travis-ci.org/kivy/python-for-android)
5+
[![Coverage Status](https://coveralls.io/repos/github/kivy/python-for-android/badge.svg?branch=master&kill_cache=1)](https://coveralls.io/github/kivy/python-for-android?branch=master)
56
[![Backers on Open Collective](https://opencollective.com/kivy/backers/badge.svg)](#backers)
67
[![Sponsors on Open Collective](https://opencollective.com/kivy/sponsors/badge.svg)](#sponsors)
78

tox.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ deps =
77
mock
88
pytest
99
virtualenv
10+
py3: coveralls
1011
# makes it possible to override pytest args, e.g.
1112
# tox -- tests/test_graph.py
1213
commands = pytest {posargs:tests/}
14+
passenv = TRAVIS TRAVIS_*
1315
setenv =
1416
PYTHONPATH={toxinidir}
1517

18+
[testenv:py3]
19+
# for py3 env we will get code coverage
20+
commands =
21+
coverage run --branch --source=pythonforandroid -m pytest {posargs:tests/}
22+
coverage report -m
23+
1624
[testenv:pep8]
1725
deps = flake8
1826
commands = flake8 pythonforandroid/ tests/ ci/

0 commit comments

Comments
 (0)