Skip to content

Commit

Permalink
Merge pull request #1835 from opacam/feature-coveralls
Browse files Browse the repository at this point in the history
Add coverage with coveralls and make use of travis stages
  • Loading branch information
AndreMiras authored Jun 6, 2019
2 parents 0482be4 + d514c37 commit 6d038fa
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 23 deletions.
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[run]
omit =
*test*

[report]
exclude_lines =
pragma: no cover
def __repr__
raise NotImplementedError
if __name__ == .__main__.:
71 changes: 48 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ dist: xenial # needed for more recent python 3 and python3-venv

language: generic

stages:
- lint
- test

services:
- docker

before_install:
- travis_retry sudo apt update -qq
- travis_retry sudo apt install -qq --no-install-recommends python2.7 python3 python3-venv python3-virtualenv
# to successfully send the coveralls reports we need pyOpenSSL
- travis_retry sudo apt install -qq --no-install-recommends
python2.7 python3 python3-venv python3-virtualenv python3-pip
python3-setuptools python3-openssl
# (venv/virtualenv are both used by tests/test_pythonpackage.py)
- sudo pip install tox>=2.0
- sudo pip3 install coveralls
# https://github.com/travis-ci/travis-ci/issues/6069#issuecomment-266546552
- git remote set-branches --add origin master
- git fetch
Expand All @@ -20,25 +28,42 @@ env:
global:
- ANDROID_SDK_HOME=/opt/android/android-sdk
- ANDROID_NDK_HOME=/opt/android/android-ndk
matrix:
- COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python3_sqlite_openssl.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,sqlite3,setuptools'
# overrides requirements to skip `peewee` pure python module, see:
# https://github.com/kivy/python-for-android/issues/1263#issuecomment-390421054
- COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python2_sqlite_openssl.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --requirements sdl2,pyjnius,kivy,python2,openssl,requests,sqlite3,setuptools'
- COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python2.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --bootstrap sdl2 --requirements python2,numpy'
# builds only the recipes that moved
- COMMAND='. venv/bin/activate && ./ci/rebuild_updated_recipes.py'

before_script:
# we want to fail fast on tox errors without having to `docker build` first
- tox -- tests/ --ignore tests/test_pythonpackage.py
# (we ignore test_pythonpackage.py since these run way too long!! test_pythonpackage_basic.py will still be run.)

script:
# Run a background process to make sure that travis will not kill our tests in
# case that the travis log doesn't produce any output for more than 10 minutes
- while sleep 540; do echo "==== Still running (travis, don't kill me) ===="; done &
- docker build --tag=p4a --file Dockerfile.py3 .
- docker run -e CI p4a /bin/sh -c "$COMMAND"
# kill the background process started before run docker
- kill %1

jobs:
include:
- stage: lint
name: "Tox tests and coverage"
script:
# we want to fail fast on tox errors without having to `docker build` first
- tox -- tests/ --ignore tests/test_pythonpackage.py
# (we ignore test_pythonpackage.py since these run way too long!!
# test_pythonpackage_basic.py will still be run.)
after_success:
- coveralls

- &testing
stage: test
before_script:
# build docker image
- docker build --tag=p4a --file Dockerfile.py3 .
# Run a background process to make sure that travis will not kill our tests in
# case that the travis log doesn't produce any output for more than 10 minutes
- while sleep 540; do echo "==== Still running (travis, don't kill me) ===="; done &
script:
- docker run -e CI -e TRAVIS_JOB_ID="$TRAVIS_JOB_ID" -e TRAVIS_BRANCH="$TRAVIS_BRANCH" p4a /bin/sh -c "$COMMAND"
after_script:
# kill the background process started before run docker
- kill %1
name: Python 3 basic
# overrides requirements to skip `peewee` pure python module, see:
# https://github.com/kivy/python-for-android/issues/1263#issuecomment-390421054
env: COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python3_sqlite_openssl.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,sqlite3,setuptools'
- <<: *testing
name: Python 2 basic
env: COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python2_sqlite_openssl.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --requirements sdl2,pyjnius,kivy,python2,openssl,requests,sqlite3,setuptools'
- <<: *testing
name: Python 2 numpy
env: COMMAND='. venv/bin/activate && cd testapps/ && python setup_testapp_python2.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --bootstrap sdl2 --requirements python2,numpy'
- <<: *testing
name: Rebuild updated recipes
env: COMMAND='. venv/bin/activate && ./ci/rebuild_updated_recipes.py'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ python-for-android
==================

[![Build Status](https://travis-ci.org/kivy/python-for-android.svg?branch=master)](https://travis-ci.org/kivy/python-for-android)
[![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)
[![Backers on Open Collective](https://opencollective.com/kivy/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/kivy/sponsors/badge.svg)](#sponsors)

Expand Down
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ deps =
mock
pytest
virtualenv
py3: coveralls
# makes it possible to override pytest args, e.g.
# tox -- tests/test_graph.py
commands = pytest {posargs:tests/}
passenv = TRAVIS TRAVIS_*
setenv =
PYTHONPATH={toxinidir}

[testenv:py3]
# for py3 env we will get code coverage
commands =
coverage run --branch --source=pythonforandroid -m pytest {posargs:tests/}
coverage report -m

[testenv:pep8]
deps = flake8
commands = flake8 pythonforandroid/ tests/ ci/
Expand Down

0 comments on commit 6d038fa

Please sign in to comment.