From 05d63e25dc787ed8022e38fbad61defed456fa02 Mon Sep 17 00:00:00 2001 From: xonix Date: Sun, 7 Jan 2024 21:48:20 +0200 Subject: [PATCH] Add code coverage badge #21 --- Makesurefile | 12 +++++++++++- README.md | 1 + coverage.svg | 26 ++++++++++++++++++++++++++ coverage.tpl.svg | 26 ++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 coverage.svg create mode 100644 coverage.tpl.svg diff --git a/Makesurefile b/Makesurefile index 5567999..da1b672 100644 --- a/Makesurefile +++ b/Makesurefile @@ -213,4 +213,14 @@ @goal coverage @doc 'prepares code coverage report' @depends_on _cover_profile_prepared - go tool cover -html="$COVERPROFILE" \ No newline at end of file + go tool cover -html="$COVERPROFILE" + +@goal coverage_badge_updated +@doc 'updates code coverage badge' +@depends_on _cover_profile_prepared + html='/tmp/cov.html' + go tool cover -html="$COVERPROFILE" -o "$html" + coverage="$(awk '/fhtagn\.awk/ { if (match($0,/\(.+\)/)) print substr($0,RSTART+1,RLENGTH-2) }' "$html")" + echo "coverage: $coverage" + awk -v coverage="$coverage" '{ gsub(/\$COVERAGE/,coverage) } 1' coverage.tpl.svg > coverage.svg + rm "$html" diff --git a/README.md b/README.md index 1e20bac..03b228d 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ # fhtagn [![Run tests](https://github.com/xonixx/fhtagn/actions/workflows/run-tests.yml/badge.svg)](https://github.com/xonixx/fhtagn/actions/workflows/run-tests.yml) +![coverage](coverage.svg) `fhtagn.awk` is a tiny CLI tool for literate testing for command-line programs. diff --git a/coverage.svg b/coverage.svg new file mode 100644 index 0000000..d4a2bcf --- /dev/null +++ b/coverage.svg @@ -0,0 +1,26 @@ + + coverage: 98.5% + + + + + + + + + + + + + + + coverage + + 98.5% + + diff --git a/coverage.tpl.svg b/coverage.tpl.svg new file mode 100644 index 0000000..169fb79 --- /dev/null +++ b/coverage.tpl.svg @@ -0,0 +1,26 @@ + + coverage: $COVERAGE + + + + + + + + + + + + + + + coverage + + $COVERAGE + + \ No newline at end of file