Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions .github/workflows/rust-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,4 @@ jobs:

# Convert the generated coverage report into overall and per-file summaries and add them to the GitHub job summary
- name: Coverage summary
run: |
echo "### Test Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
./.shared/scripts/coverage/coverage_summary.sh < /tmp/coverage.json >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "<details><summary>Per-file coverage</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
./.shared/scripts/coverage/coverage_per_file.sh < /tmp/coverage.json >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
run: ./.shared/scripts/coverage/coverage_report.sh < /tmp/coverage.json >> "$GITHUB_STEP_SUMMARY"
15 changes: 0 additions & 15 deletions scripts/coverage/coverage_per_file.sh

This file was deleted.

39 changes: 39 additions & 0 deletions scripts/coverage/coverage_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# Generate coverage report in markdown format from cargo-llvm-cov JSON output.
# Reads cargo-llvm-cov JSON output from stdin and outputs markdown to stdout
# Usage: cargo llvm-cov --json ... | ./scripts/coverage/coverage_report.sh


set -euo pipefail

echo "### Test Coverage Report"
echo ""

# Overall coverage summary
jq -r '
.data[0].totals |
"| Metric | Covered | Total | Coverage |",
"| ------ | ------: | ----: | -------: |",
"| Lines | \(.lines.covered) | \(.lines.count) | \(.lines.percent * 100 | round / 100)% |",
"| Functions | \(.functions.covered) | \(.functions.count) | \(.functions.percent * 100 | round / 100)% |",
"| Regions | \(.regions.covered) | \(.regions.count) | \(.regions.percent * 100 | round / 100)% |",
"| Instantiations | \(.instantiations.covered) | \(.instantiations.count) | \(.instantiations.percent * 100 | round / 100)% |"
'

echo ""
echo "<details><summary>Per-file coverage</summary>"
echo ""

# Per-file coverage table
jq -r '
"| File | Lines | Functions | Regions | Line Coverage |",
"| ---- | ----: | --------: | ------: | -----------: |",
(.data[0].files | sort_by(-.summary.lines.percent) | .[] |
.filename as $f |
.summary |
"| \($f | split("/") | .[-3:] | join("/")) | \(.lines.covered)/\(.lines.count) | \(.functions.covered)/\(.functions.count) | \(.regions.covered)/\(.regions.count) | \(.lines.percent * 100 | round / 100)% |"
)
'

echo ""
echo "</details>"
15 changes: 0 additions & 15 deletions scripts/coverage/coverage_summary.sh

This file was deleted.