Files
loki/tools/diff_coverage.sh
Travis Patterson 03153e89bf clean up the pr diff message (#6098)
* clean up the pr diff message

* add dependency to clone-main to avoid possible race

* don't start tests before everything is cloned

* formatting change
2022-05-04 23:38:58 +02:00

24 lines
662 B
Bash
Executable File

#!/bin/bash
if [[ ! -f "$1" ]] || [[ ! -f "$2" ]]; then
echo "unable to compare test coverage: both old and new files must exist"
exit 0
fi
echo
echo
echo '**Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.**'
echo
echo '```diff'
for pkg in ${3//,/ }; do
old=$(grep "pkg/${pkg}\s" "$1" | sed s/%// | awk '{print $5}')
new=$(grep "pkg/${pkg}\s" "$2" | sed s/%// | awk '{print $5}')
echo | awk -v pkg="${pkg}" -v old="${old:-0}" -v new="${new:-0}" \
'{
sign=new - old < 0 ? "-" : "+"
printf ("%s %18s\t%s%%\n", sign, pkg, new - old)
}'
done
echo '```'