nix/coverage-html: use line coverage for badge number
Build and test / build (push) Successful in 56s
Build and test / build-freebsd-cross (push) Successful in 1m2s
Build and test / test (push) Successful in 1m6s

This commit is contained in:
2026-06-11 17:55:13 +09:00
parent 28ddaff0b7
commit ee2b648c9a
+6 -4
View File
@@ -59,15 +59,17 @@ stdenv.mkDerivation {
llvm-cov show "''${LLVM_COV_ARGS[@]}"
# Skip "Totals" and "Function Coverage", get "Line Coverage"
TOTAL_COVERAGE="$(
htmlq 'td > pre' <coverage-html/index.html \
| sed '0,/^<pre>Totals<\/pre>$/d' \
| head -n 1 \
| sed -e 's/<pre>[[:space:]]*//' -e 's/%.*$/%/' \
| sed -e '0,/^<pre>Totals<\/pre>$/d' \
| sed -n -e '2,1p' \
| sed -e 's/<pre>[[:space:]]*//' \
| sed -e 's/%.*$/%/'
)"
if [[ "$TOTAL_COVERAGE" == *% ]]; then
COVERAGE_VALUE="''${TOTAL_COVERAGE%\%}"
COVERAGE_VALUE="$(printf "%.0f" "''${TOTAL_COVERAGE%\%}")"
if [[ "$COVERAGE_VALUE" -ge 80 ]]; then
COLOR="green"
elif [[ "$COVERAGE_VALUE" -ge 50 ]]; then