Skip to content

Commit e93458b

Browse files
authored
prettier test coverage reporting (#63)
* include git branch and coverage summary in report directory names * refactoring typo * hex encode, instead of urlencode, to work around GitHub Pages quirk
1 parent 45c3c05 commit e93458b

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

bin/publish-coverage

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,43 @@ git fetch --depth=1 --filter=blob:none origin "$branch"
3838
git sparse-checkout set dummy/
3939
git checkout "$branch"
4040

41-
# e.g. "2022-12-29 22:09:54 UTC (6c6e440)"
42-
coverage_report_name() {
43-
commit_time_iso=$(git show -s --format=%cI)
44-
commit_hash_short=$(git rev-parse HEAD | head -c 7)
45-
46-
date "--date=$commit_time_iso" --iso-8601=seconds --utc | \
47-
sed -e 's/T/ /' -e "s/+.*/ UTC ($commit_hash_short)/"
41+
hex_encode() {
42+
string=$1
43+
while [ -n "$string" ]; do
44+
tail=${string#?}
45+
head=${string%"$tail"}
46+
printf '%02x' "'$head"
47+
string=$tail
48+
done
49+
printf '\n'
4850
}
4951

5052
cd "$tracer_dir"
51-
report_name=$(coverage_report_name)
53+
54+
commit_time_iso=$(git show -s --format=%cI)
55+
commit_hash_short=$(git rev-parse HEAD | head -c 7)
56+
commit_branch=$(git branch --show-current)
57+
branch_encoded=$(hex_encode "$commit_branch")
58+
commit_time_iso=$(date "--date=$commit_time_iso" --iso-8601=ns --utc | \
59+
sed -e 's/,/./g' -e 's/......+00:00$/Z/')
60+
coverage_lines=$(grep -A 3 Lines .coverage/report/index.html | \
61+
sed -n 's/.*>\([0-9.]\+\).*/\1/p' | \
62+
paste -s | \
63+
awk '{print "lines:"$1":"$2":"$3}')
64+
coverage_funcs=$(grep -A 3 Functions .coverage/report/index.html | \
65+
sed -n 's/.*>\([0-9.]\+\).*/\1/p' | \
66+
paste -s | \
67+
awk '{print "funcs:"$1":"$2":"$3}')
68+
report_name=$(printf '%s-%s-%s-%s-%s\n' \
69+
"$commit_time_iso" \
70+
"$commit_hash_short" \
71+
"$coverage_lines" \
72+
"$coverage_funcs" \
73+
"$branch_encoded")
74+
5275
mv .coverage/report "$temp_dir/dd-trace-cpp-coverage/$report_name"
5376

5477
cd "$temp_dir/dd-trace-cpp-coverage"
5578
git add -A --sparse
56-
git commit -m "add $report_name"
79+
git commit -m "coverage for commit $commit_hash_short on $commit_branch"
5780
git push

0 commit comments

Comments
 (0)