Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git Action to run coverage #5

Open
c-bik opened this issue Apr 28, 2020 · 1 comment
Open

Git Action to run coverage #5

c-bik opened this issue Apr 28, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@c-bik
Copy link
Contributor

c-bik commented Apr 28, 2020

TBD:

  1. apt-get install lcov in dderl_dev container (FYI @walter-weinmann)
  2. @c-bik to provide a script to error out when overall coverage below parameterized coverage
  3. @shamis add konnexionsw/ora_bench_db from docker hub into action (or another way to start a oracle DB)
  4. @c-bik / @walter-weinmann to find a to dynamically define Oracle DB IP into rebar3 eunit config

I wanted to add all of us assigned to it but current git subscription doesn't allow that

@c-bik c-bik added the enhancement New feature or request label Apr 28, 2020
@c-bik
Copy link
Contributor Author

c-bik commented Apr 28, 2020

@shamis please try

oranif/cover.sh

Lines 1 to 34 in b416c80

#!/bin/bash
target_coverage=${1:-100}
rm -f coverage.info
# capture coverage info
lcov --quiet --directory . --capture --output-file coverage.info
# header files are not covered
lcov --quiet --remove coverage.info "*/odpi/src/*.c" "*.h" --output-file coverage.info
# Sample structure of lcov --summary coverage.info
# Reading tracefile coverage.info
# Summary coverage rate:
# lines......: 13.2% (142 of 1078 lines)
# functions..: 21.1% (12 of 57 functions)
# branches...: no data found
#
# grep to find the 'lines...' line with total % (e,g, 13.2 above)
lc_summary=$(lcov --summary coverage.info 2>&1 | grep -zo "lines[.]\+: [0-9.]\+" | tr '\0' '\n')
# stip off the rest to get the number
current_coverage=$(echo $lc_summary | sed 's/lines\.*: \(.*\)/\1/')
# calculate difference to target
result=$(awk 'BEGIN { print('$current_coverage'<'$target_coverage')?"F":"P"}')
if [ "$result" = "P" ]; then
exit 0
else
lcov --list coverage.info
echo "------------------------"
echo "TARGET : $target_coverage %"
echo "CURRENT : $current_coverage %"
echo "------------------------"
exit 1
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants