-
Notifications
You must be signed in to change notification settings - Fork 149
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
output coverage summary (gitlab integration) #556
Comments
Found a workaround using
And then I use |
Any PR is welcome. |
Would you add this as a new |
I'm fine with |
Duplicate of #468? |
No, #468 is about generating a full report in the Cobertura format, while this ticket is about just producing a summary (nb of lines covered / total nb of lines) for GitLab summary. |
This is what I currently do for Gitlab. I use script:
# Coverage commands go here...
# Extract and print percentage from Cobertura. See Gitlab issue #21549
- >
export COVERAGE_DEC=$(
xmlstarlet sel -t -v "number(//coverage/@line-rate)"
<cobertura.xml 2>/dev/null
)
- export COVERAGE_PCT=$(echo "100 * $COVERAGE_DEC" | bc)
- printf "gitlab-coverage %s%%\n" "$COVERAGE_PCT"
coverage: '/^gitlab-coverage .+%$/' Full CI file is here. |
I think .ctest:
stage: test
script:
- ctest --test-dir ./build -j $(nproc) --no-tests=error --output-on-failure --output-junit ctest_junit.xml
- mkdir ./build/coverage/
- grcov ./build -s ./ --threads $(nproc) --branch --output-types html,cobertura,markdown -o ./build/coverage/ --ignore '/usr/include*' --ignore '*build*' --ignore '*lib*'
- cat ./build/coverage/markdown.md
coverage: /Total coverage:.*\s+(\d*\.?\d+\%)/
artifacts:
paths:
- ./build/coverage/
reports:
junit: build/ctest_junit.xml
coverage_report:
coverage_format: cobertura
path: ./build/coverage/cobertura.xml I output as |
@gdesmott thanks for the hint on lcov. I ended up using grcov_args=(
--binary-path target/debug
--source-dir src
--ignore '/*'
--branch
# grcov needs help finding llvm-profdata, apparently
--llvm-path "$(dirname "$(which llvm-profdata)")"
)
grcov "${grcov_args[@]}" -t html -o target/coverage/html .
grcov "${grcov_args[@]}" -t lcov -o target/coverage/lcov .
lcov --list target/coverage/lcov 2>/dev/null \
| tee target/coverage/summary.txt |
i assume |
Yes, I think that's the idea. |
Add a --print-summary option along the lines of what gcovr supports and outputting in a compatible format. The number of functions covered isn't output (it is with gcovr) as this is more complicated to calculate and it's unclear if it would be useful. Fixes mozilla#556
It would be great to have an easy way to output on stdout the coverage summary in a way easily parsable by gitlab.
The text was updated successfully, but these errors were encountered: