mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 14:09:13 +00:00
21 lines
687 B
Bash
Executable File
21 lines
687 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}")")"
|
|
|
|
go test ./... -coverprofile "$SCRIPT_DIR/coverage.out"
|
|
go tool cover -html="$SCRIPT_DIR/coverage.out" -o "$SCRIPT_DIR/coverage.html"
|
|
COVERAGE=$(go tool cover -func="$SCRIPT_DIR/coverage.out" | grep total: | grep -Eo '[0-9]+\.[0-9]+')
|
|
|
|
echo
|
|
echo "coverage: $COVERAGE% of statements"
|
|
|
|
COLOR=orange
|
|
if (( $(echo "$COVERAGE <= 50" | bc -l) )) ; then
|
|
COLOR=red
|
|
elif (( $(echo "$COVERAGE > 80" | bc -l) )); then
|
|
COLOR=green
|
|
fi
|
|
curl -s "https://img.shields.io/badge/coverage-$COVERAGE%25-$COLOR" > "$SCRIPT_DIR/coverage.svg"
|
|
|
|
git add "$SCRIPT_DIR/coverage.html" "$SCRIPT_DIR/coverage.svg" |