[libvirt] [PATCH 1/1] CI: add code coverage analysis

claudioandre.br at gmail.com claudioandre.br at gmail.com
Thu May 25 04:14:36 UTC 2017


From: Claudio André <claudioandre.br at gmail.com>

It builds the code coverage report and uploads the coverage data to a web service in order to allow to track libvirt's code coverage over time.
---
 .travis.yml | 11 ++++++++++-
 README.md   |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 266ffff..24b8d6c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -39,6 +39,7 @@ addons:
       - dnsmasq-base
       - librbd-dev
       - w3c-dtd-xhtml
+      - lcov
 
 notifications:
   irc:
@@ -64,7 +65,8 @@ before_install:
 
 # the custom PATH is just to pick up OS-X homebrew & its harmless on Linux
 before_script:
-  - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" ./autogen.sh
+  - PATH="/usr/local/opt/gettext/bin:/usr/local/opt/rpcgen/bin:$PATH" ./autogen.sh "$COVERAGE"
+  - gem install coveralls-lcov
 script:
   - VIR_TEST_DEBUG=1 make -j3 && make -j3 syntax-check && make -j3 check
 
@@ -77,9 +79,16 @@ matrix:
       dist: trusty
     - compiler: gcc
       dist: trusty
+      env: COVERAGE="--enable-test-coverage"
     - compiler: clang
       os: osx
       script:
         # many unit tests fail & so does syntax-check, so skip for now
         # one day we must fix it though....
         - make -j3
+
+after_success:
+  - 'if [ -n "${COVERAGE}" ]; then
+        make -j3 cov;
+        coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage/libvirt.info;
+    fi'
diff --git a/README.md b/README.md
index 1035bcf..021f71b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
 [![Build Status](https://travis-ci.org/libvirt/libvirt.svg)](https://travis-ci.org/libvirt/libvirt)
+[![Coverage Status](https://coveralls.io/repos/github/libvirt/libvirt/badge.svg)](https://coveralls.io/github/libvirt/libvirt)
 
 Libvirt API for virtualization
 ==============================
-- 
2.11.0




More information about the libvir-list mailing list