Skip to content

Commit

Permalink
Add code coverage badge #21
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Jan 7, 2024
1 parent 9211d60 commit 05d63e2
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Makesurefile
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,14 @@
@goal coverage
@doc 'prepares code coverage report'
@depends_on _cover_profile_prepared
go tool cover -html="$COVERPROFILE"
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"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
26 changes: 26 additions & 0 deletions coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions coverage.tpl.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 05d63e2

Please sign in to comment.