CI: preprocess coverage with lcov for codecov.io

We preprocess gcov output with lcov before feeding it to
codecov. For the following reasons:
* codecov seems to support LCOV pseudo-pragmas only if
  they match the pattern "// LCOV_EXCL"
* It is easier to understand what will happen in codecov
  if we feed a preprocessed lcov file than a pile of raw
  gcov files
* We can reproduce that step locally and therefore do
  quicker trials
* Branch coverage is not correct when feeding gcov raw
  input to codecov

+ We avoid feeding gcovr's output to codecov:
Codecov upload bash script also sees shippable/codecoverage/coverage.xml
but when this is uploaded together with lcov's the branch coverage
is not correct, and some not compiled in files are reported as not
covered.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This commit is contained in:
Alberto Escolar Piedras 2018-02-03 20:35:15 +01:00 committed by Anas Nashif
commit d82ff1770d

View file

@ -78,10 +78,12 @@ build:
- >
if [ "$MATRIX_BUILD" = "1" ]; then
gcovr -r ${ZEPHYR_BASE} -x > shippable/codecoverage/coverage.xml;
mv sanity-out/native_posix/ coverage_native_posix/;
lcov --capture --directory sanity-out/native_posix/ --output-file lcov.pre.info -q --rc lcov_branch_coverage=1;
lcov -q --remove lcov.pre.info *generated* -o lcov.info --rc lcov_branch_coverage=1;
rm lcov.pre.info;
rm -rf sanity-out out-2nd-pass;
bash <(curl -s https://codecov.io/bash) -f '!*.lst' -X coveragepy -X fixes;
rm -rf coverage_native_posix/;
bash <(curl -s https://codecov.io/bash) -f "lcov.info" -X coveragepy -X fixes;
rm lcov.info;
else
rm -rf sanity-out out-2nd-pass;
fi;
@ -101,10 +103,12 @@ build:
- >
if [ "$MATRIX_BUILD" = "1" ]; then
gcovr -r ${ZEPHYR_BASE} -x > shippable/codecoverage/coverage.xml;
mv sanity-out/native_posix/ coverage_native_posix/;
lcov --capture --directory sanity-out/native_posix/ --output-file lcov.pre.info -q --rc lcov_branch_coverage=1;
lcov -q --remove lcov.pre.info *generated* -o lcov.info --rc lcov_branch_coverage=1;
rm lcov.pre.info;
rm -rf sanity-out out-2nd-pass;
bash <(curl -s https://codecov.io/bash) -f '!*.lst' -X coveragepy -X fixes;
rm -rf coverage_native_posix/;
bash <(curl -s https://codecov.io/bash) -f "lcov.info" -X coveragepy -X fixes;
rm lcov.info;
else
rm -rf sanity-out out-2nd-pass;
fi;