From ee2b648c9a5be8ce2ab1bc6e91ece62ca56ed041 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Thu, 11 Jun 2026 17:55:13 +0900 Subject: [PATCH] nix/coverage-html: use line coverage for badge number --- nix/coverage-html.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nix/coverage-html.nix b/nix/coverage-html.nix index b539172..278944f 100644 --- a/nix/coverage-html.nix +++ b/nix/coverage-html.nix @@ -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' Totals<\/pre>$/d' \ - | head -n 1 \ - | sed -e 's/
[[:space:]]*//' -e 's/%.*$/%/' \
+      | sed -e '0,/^
Totals<\/pre>$/d' \
+      | sed -n -e '2,1p' \
+      | sed -e 's/
[[: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