Skip to content

Commit

Permalink
fix diffless diff coverage report
Browse files Browse the repository at this point in the history
  • Loading branch information
mdekstrand committed Jul 24, 2024
1 parent 56c7273 commit b21f7f1
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions utils/coverage-log.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ if {[ev GITHUB_BASE_REF base]} {

set diff_lines [exec jq .total_num_lines diff-cover.json]
set diff_bad [exec jq .total_num_violations diff-cover.json]
set diff_cov [expr {1.0 - ($diff_bad / $diff_lines)}]
if {$diff_lines > 0} {
set diff_cov [expr {1.0 - ($diff_bad / $diff_lines)}]
} else {
set diff_cov NA
}

set prev_cov [exec jq .totals.percent_covered <<$prev_data 2>@stderr]
set cur_cov [exec jq .totals.percent_covered coverage.json 2>&stderr]
Expand All @@ -51,10 +55,17 @@ if {[ev GITHUB_BASE_REF base]} {
# write the coverage report
set reph [open lenskit-coverage/report.md w]
puts $reph "The GitHub 🤖 has run the tests on your PR.\n"
puts $reph [format
"Covered **%.2f%%** of diff (coverage changed **%.2f%%** from %.2f%% to %.2f%%).\n"
$diff_cov $cov_change $prev_cov $cur_cov
]
if {$diff_cov eq "NA"} {
puts $reph [format
"Covered **no lines** of diff (coverage changed **%.2f%%** from %.2f%% to %.2f%%).\n"
$cov_change $prev_cov $cur_cov
]
} else {
puts $reph [format
"Covered **%.2f%%** of diff (coverage changed **%.2f%%** from %.2f%% to %.2f%%).\n"
$diff_cov $cov_change $prev_cov $cur_cov
]
}

set dsh [open diff-cover.md r]
while {[gets $dsh line] >= 0} {
Expand Down

0 comments on commit b21f7f1

Please sign in to comment.