mirror of
https://github.com/grafana/loki.git
synced 2025-07-25 16:15:16 +08:00

* 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
24 lines
662 B
Bash
Executable File
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 '```'
|