mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
Coverage hook.
This commit is contained in:
1707
.github/coverage.html
vendored
Normal file
1707
.github/coverage.html
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
.github/coverage.sh
vendored
16
.github/coverage.sh
vendored
@@ -1,15 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
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 "Full coverage: $COVERAGE% of statements"
|
||||
|
||||
go test ../... -coverprofile coverage.svg
|
||||
COVERAGE=$(go tool cover -func=coverage.svg | grep total: | grep -Eo '[0-9]+\.[0-9]+')
|
||||
echo $COVERAGE
|
||||
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" > coverage.svg
|
||||
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"
|
||||
Reference in New Issue
Block a user