diff --git a/.travis.yml b/.travis.yml index 7d2823ca..a3581861 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ dist: xenial cache: pip: true cargo: true + directories: + - "$HOME/kcov" matrix: include: @@ -56,7 +58,16 @@ install: script: - ./ci/travis/test.sh +after_success: + - ./ci/travis/cover.sh + deploy: + - provider: script + skip_cleanup: true + script: ./ci/travis/cover.sh + on: + branch: master + condition: $TRAVIS_EVENT_TYPE != "cron" - provider: script skip_cleanup: true script: ./ci/travis/guide.sh diff --git a/README.md b/README.md index c6f439c3..bb7645d6 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.org/PyO3/pyo3.svg?branch=master)](https://travis-ci.org/PyO3/pyo3) [![Build Status](https://ci.appveyor.com/api/projects/status/github/PyO3/pyo3?branch=master&svg=true)](https://ci.appveyor.com/project/fafhrd91/pyo3) +[![codecov](https://codecov.io/gh/PyO3/pyo3/branch/master/graph/badge.svg)](https://codecov.io/gh/PyO3/pyo3) [![crates.io](http://meritbadge.herokuapp.com/pyo3)](https://crates.io/crates/pyo3) [![Join the dev chat](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/PyO3/Lobby) diff --git a/ci/travis/cover.sh b/ci/travis/cover.sh new file mode 100755 index 00000000..e9981093 --- /dev/null +++ b/ci/travis/cover.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -ex + +### Run kcov in parallel ####################################################### + +rm -f target/debug/pyo3*.d +rm -f target/debug/test_*.d +rm -f target/debug/test_doc-* + +FILES=$(find . -path ./target/debug/pyo3\* -or -path ./target/debug/test_\*) +echo $FILES | xargs -n1 -P $(nproc) sh -c ' + dir="target/cov/$(basename $@)" + mkdir -p $dir + echo "Collecting coverage data of $(basename $@)" + kcov \ + --exclude-path=./tests \ + --exclude-region="#[cfg(test)]:#[cfg(testkcovstopmarker)]" \ + --exclude-pattern=/.cargo,/usr/lib \ + --verify $dir "$@" 2>&1 >/dev/null +' _ + +### Upload coverage ############################################################ + +echo "Uploading code coverage" +curl -SsL https://codecov.io/bash | bash diff --git a/ci/travis/setup.sh b/ci/travis/setup.sh index 9ae10672..b7e58f42 100755 --- a/ci/travis/setup.sh +++ b/ci/travis/setup.sh @@ -18,3 +18,18 @@ PYTHON_LIB=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PYTHON_LIB:$HOME/rust/lib" echo ${LD_LIBRARY_PATH} + +### Setup kcov ################################################################# + +if [ ! -f "$HOME/.cargo/bin/kcov" ]; then + if [ ! -d "$HOME/kcov/.git" ]; then + git clone --depth=1 https://github.com/SimonKagstrom/kcov "$HOME/kcov" + fi + + cd $HOME/kcov + git pull + cmake . + make + install src/kcov $HOME/.cargo/bin/kcov + cd $TRAVIS_BUILD_DIR +fi diff --git a/ci/travis/test.sh b/ci/travis/test.sh index 51011e8c..73e4b00e 100755 --- a/ci/travis/test.sh +++ b/ci/travis/test.sh @@ -3,6 +3,7 @@ set -ex cargo clean cargo test --features "$FEATURES num-complex" +( cd pyo3-derive-backend; cargo test ) if [ $TRAVIS_JOB_NAME = 'Minimum nightly' ]; then cargo fmt --all -- --check cargo clippy --features "$FEATURES num-complex"