Merge pull request #397 from Alexander-N/coverage

Reactivate coverage on CI
This commit is contained in:
konstin 2019-03-18 15:11:51 +01:00 committed by GitHub
commit 7cdd253593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 0 deletions

View File

@ -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

View File

@ -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)

26
ci/travis/cover.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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"