From 44854a7495f705bc26b7bed410ae4c11f4fb17b1 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Thu, 26 Jan 2023 10:10:13 +0000 Subject: [PATCH] Coverage hook. --- .github/coverage.html | 1707 +++++++++++++++++++++++++++++++++++++++++ .github/coverage.sh | 16 +- README.md | 2 +- 3 files changed, 1719 insertions(+), 6 deletions(-) create mode 100644 .github/coverage.html diff --git a/.github/coverage.html b/.github/coverage.html new file mode 100644 index 0000000..17fbf6e --- /dev/null +++ b/.github/coverage.html @@ -0,0 +1,1707 @@ + + + + + + go-sqlite3: Go Coverage Report + + + +
+ +
+ not tracked + + not covered + covered + +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/.github/coverage.sh b/.github/coverage.sh index 3a72ea5..bee0026 100755 --- a/.github/coverage.sh +++ b/.github/coverage.sh @@ -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" \ No newline at end of file diff --git a/README.md b/README.md index 9b696ad..324feeb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Go Reference](https://pkg.go.dev/badge/image)](https://pkg.go.dev/github.com/ncruces/go-sqlite3) [![Go Report](https://goreportcard.com/badge/github.com/ncruces/go-sqlite3)](https://goreportcard.com/report/github.com/ncruces/go-sqlite3) -![Go Coverage](.github/coverage.svg) +[![Go Coverage](.github/coverage.svg)](https://raw.githack.com/ncruces/go-sqlite3/main/.github/coverage.html) ⚠️ CAUTION ⚠️