Merge pull request #786 from fonttools/combine-coverage

run coverage on all python versions; upload combined data to codecov
This commit is contained in:
Cosimo Lupo 2016-12-26 19:14:06 +00:00 committed by GitHub
commit 9a28b61e3c
10 changed files with 95 additions and 82 deletions

View File

@ -2,32 +2,22 @@ environment:
matrix: matrix:
- JOB: "2.7.12 32-bit" - JOB: "2.7.12 32-bit"
PYTHON_HOME: "C:\\Python27" PYTHON_HOME: "C:\\Python27"
TOXENV: "py27" TOXENV: "py27-cov"
TOXPYTHON: "C:\\Python27\\python.exe" TOXPYTHON: "C:\\Python27\\python.exe"
- JOB: "3.4.4 32-bit"
PYTHON_HOME: "C:\\Python34"
TOXENV: "py34"
TOXPYTHON: "C:\\Python34\\python.exe"
- JOB: "3.5.2 32-bit" - JOB: "3.5.2 32-bit"
PYTHON_HOME: "C:\\Python35" PYTHON_HOME: "C:\\Python35"
TOXENV: "py35" TOXENV: "py35-cov"
TOXPYTHON: "C:\\Python35\\python.exe" TOXPYTHON: "C:\\Python35\\python.exe"
- JOB: "2.7.12 64-bit" - JOB: "2.7.12 64-bit"
PYTHON_HOME: "C:\\Python27-x64" PYTHON_HOME: "C:\\Python27-x64"
TOXENV: "py27" TOXENV: "py27-cov"
TOXPYTHON: "C:\\Python27-x64\\python.exe" TOXPYTHON: "C:\\Python27-x64\\python.exe"
- JOB: "3.4.4 64-bit"
PYTHON_HOME: "C:\\Python34-x64"
TOXENV: "py34"
TOXPYTHON: "C:\\Python34-x64\\python.exe"
- JOB: "3.5.2 64-bit" - JOB: "3.5.2 64-bit"
PYTHON_HOME: "C:\\Python35-x64" PYTHON_HOME: "C:\\Python35-x64"
TOXENV: "py35" TOXENV: "py35-cov"
TOXPYTHON: "C:\\Python35-x64\\python.exe" TOXPYTHON: "C:\\Python35-x64\\python.exe"
install: install:
@ -50,10 +40,9 @@ install:
# upgrade pip and setuptools to avoid out-of-date warnings # upgrade pip and setuptools to avoid out-of-date warnings
- "python -m pip install --disable-pip-version-check --user --upgrade pip setuptools" - "python -m pip install --disable-pip-version-check --user --upgrade pip setuptools"
- "python -m pip --version"
# install the dependencies to run the tests # install the dependencies to run the tests
- "python -m pip install -r dev-requirements.txt" - "python -m pip install tox"
build: false build: false
@ -61,6 +50,9 @@ build: false
test_script: test_script:
- "tox" - "tox"
after_test:
- "tox -e codecov"
notifications: notifications:
- provider: Email - provider: Email
to: to:

5
.codecov.yml Normal file
View File

@ -0,0 +1,5 @@
comment: false
coverage:
status:
project: off
patch: off

View File

@ -3,9 +3,15 @@
# See: http://coverage.readthedocs.org/en/coverage-4.0.3/branch.html#branch # See: http://coverage.readthedocs.org/en/coverage-4.0.3/branch.html#branch
branch = True branch = True
# list of directories to measure # list of directories or packages to measure
source = fontTools
# these are treated as equivalent when combining data
[paths]
source = source =
Lib/fontTools Lib/fontTools
.tox/*/lib/python*/site-packages/fontTools
.tox/pypy*/site-packages/fontTools
[report] [report]
# Regexes for lines to exclude from consideration # Regexes for lines to exclude from consideration

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ dist
.tox/* .tox/*
.cache/ .cache/
.coverage .coverage
.coverage.*
htmlcov/ htmlcov/
# emacs backup files # emacs backup files

View File

@ -5,26 +5,24 @@ language: python
matrix: matrix:
include: include:
- python: 2.7 - python: 2.7
env: TOXENV=py27 env: TOXENV=py27-cov
- python: 3.4 - python: 3.4
env: TOXENV=py34 env: TOXENV=py34-cov
- python: 3.5 - python: 3.5
env: env:
- TOXENV=py35 - TOXENV=py35-cov
- BUILD_DIST=true - BUILD_DIST=true
- python: 3.6 - python: 3.6
env: TOXENV=py36 env: TOXENV=py36-cov
- python: pypy - python: pypy
env: TOXENV=pypy # disable coverage.py on pypy because of performance problems
env: TOXENV=pypy-nocov
- language: generic - language: generic
os: osx os: osx
env: TOXENV=py27 env: TOXENV=py27-cov
- language: generic - language: generic
os: osx os: osx
env: TOXENV=py35 env: TOXENV=py36-cov
# coveralls is not listed in tox's envlist, but should run in travis
- python: 3.5
env: TOXENV=coveralls
install: install:
- ./.travis/install.sh - ./.travis/install.sh
@ -32,6 +30,9 @@ install:
script: script:
- ./.travis/run.sh - ./.travis/run.sh
after_success:
- ./.travis/after_success.sh
before_deploy: before_deploy:
- ./.travis/before_deploy.sh - ./.travis/before_deploy.sh

11
.travis/after_success.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -e
set -x
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
source .venv/bin/activate
fi
# upload coverage data to Codecov.io
[[ ${TOXENV} == *"-cov"* ]] && tox -e codecov

View File

@ -3,34 +3,31 @@
set -e set -e
set -x set -x
pip_options="--upgrade"
ci_requirements="pip setuptools tox" ci_requirements="pip setuptools tox"
if [[ "$(uname -s)" == 'Darwin' ]]; then if [ "$TRAVIS_OS_NAME" == "osx" ]; then
# install pyenv from the git repo (quicker than using brew) if [[ ${TOXENV} == *"py27"* ]]; then
git clone https://github.com/yyuu/pyenv.git ~/.pyenv # install pip on the system python
PYENV_ROOT="$HOME/.pyenv" curl -O https://bootstrap.pypa.io/get-pip.py
PATH="$PYENV_ROOT/bin:$PATH" python get-pip.py --user
eval "$(pyenv init -)" # install virtualenv and create virtual environment
python -m pip install --user virtualenv
case "${TOXENV}" in python -m virtualenv .venv/
py27) elif [[ ${TOXENV} == *"py3"* ]]; then
# install pip on the system python # install/upgrade current python3 with homebrew
curl -O https://bootstrap.pypa.io/get-pip.py if brew list --versions python3 > /dev/null; then
python get-pip.py --user brew upgrade python3
;; else
py35) brew install python3
pyenv install 3.5.2 fi
pyenv global 3.5.2 # create virtual environment
;; python3 -m venv .venv/
esac else
pyenv rehash echo "unsupported $TOXENV: "${TOXENV}
exit 1
# add --user option so we don't require sudo fi
pip_options="$pip_options --user" # activate virtual environment
else source .venv/bin/activate
# on Linux, we're already in a virtualenv; no --user required
:
fi fi
python -m pip install $pip_options $ci_requirements python -m pip install $ci_requirements

View File

@ -3,12 +3,8 @@
set -e set -e
set -x set -x
if [[ "$(uname -s)" == "Darwin" ]]; then if [ "$TRAVIS_OS_NAME" == "osx" ]; then
PYENV_ROOT="$HOME/.pyenv" source .venv/bin/activate
PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi fi
# tox script may not be in the $PATH if we installed as --user tox
# so we run it as module
python -m tox

View File

@ -1,7 +1,7 @@
[![Travis Build Status](https://travis-ci.org/fonttools/fonttools.svg)](https://travis-ci.org/fonttools/fonttools) [![Travis Build Status](https://travis-ci.org/fonttools/fonttools.svg)](https://travis-ci.org/fonttools/fonttools)
[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/0f7fmee9as744sl7/branch/master?svg=true)](https://ci.appveyor.com/project/fonttools/fonttools/branch/master) [![Appveyor Build status](https://ci.appveyor.com/api/projects/status/0f7fmee9as744sl7/branch/master?svg=true)](https://ci.appveyor.com/project/fonttools/fonttools/branch/master)
[![Health](https://landscape.io/github/behdad/fonttools/master/landscape.svg?style=flat)](https://landscape.io/github/behdad/fonttools/master) [![Health](https://landscape.io/github/behdad/fonttools/master/landscape.svg?style=flat)](https://landscape.io/github/behdad/fonttools/master)
[![Coverage Status](https://coveralls.io/repos/github/fonttools/fonttools/badge.svg?branch=master)](https://coveralls.io/github/fonttools/fonttools?branch=master) [![Coverage Status](https://codecov.io/gh/fonttools/fonttools/branch/master/graph/badge.svg)](https://codecov.io/gh/fonttools/fonttools)
[![PyPI](https://img.shields.io/pypi/v/fonttools.svg)](https://pypi.org/project/FontTools) [![PyPI](https://img.shields.io/pypi/v/fonttools.svg)](https://pypi.org/project/FontTools)
### What is this? ### What is this?

44
tox.ini
View File

@ -1,6 +1,5 @@
[tox] [tox]
envlist = py27, py35, py36 envlist = py{27,35,36}-cov, htmlcov
skip_missing_interpreters = true
[testenv] [testenv]
basepython = basepython =
@ -10,33 +9,38 @@ basepython =
py35: {env:TOXPYTHON:python3.5} py35: {env:TOXPYTHON:python3.5}
py36: {env:TOXPYTHON:python3.6} py36: {env:TOXPYTHON:python3.6}
deps = deps =
# we install coverage from source until 4.3 is released, because of this:
# https://bitbucket.org/ned/coveragepy/pull-requests/118/check-source-isdir-not-just-exists-there/diff
cov: hg+https://bitbucket.org/ned/coveragepy#egg=coverage
pytest pytest
-rrequirements.txt -rrequirements.txt
install_command = install_command =
{envpython} -m pip install -v {opts} {packages} pip install -v {opts} {packages}
commands = commands =
# run the test suite against the package installed inside tox env # run the test suite against the package installed inside tox env.
py.test {posargs:--pyargs fontTools} # We use parallel mode and then combine later so that coverage.py will take
# paths like .tox/py36/lib/python3.6/site-packages/fontTools and collapse
# them into Lib/fontTools.
cov: coverage run --parallel-mode -m pytest {posargs:--pyargs fontTools}
nocov: pytest {posargs:--pyargs fontTools}
[testenv:coverage] [testenv:htmlcov]
basepython = {env:TOXPYTHON:python3.5} basepython = {env:TOXPYTHON:python3.5}
deps = deps =
{[testenv]deps} hg+https://bitbucket.org/ned/coveragepy#egg=coverage
pytest-cov
skip_install = true skip_install = true
commands= commands =
# measure test coverage and create html report coverage combine
py.test --cov --cov-report html {posargs} coverage html
[testenv:coveralls] [testenv:codecov]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH passenv = *
basepython=python3.5 basepython = {env:TOXPYTHON:python}
deps = deps =
{[testenv:coverage]deps} hg+https://bitbucket.org/ned/coveragepy#egg=coverage
coveralls codecov
skip_install = true skip_install = true
ignore_outcome = true ignore_outcome = true
commands= commands =
# measure test coverage and upload report to coveralls coverage combine
py.test --cov codecov --env TOXENV
coveralls