Created
September 21, 2020 04:37
-
-
Save jacygao/716f47f60f685c5df3aea0e096886ba9 to your computer and use it in GitHub Desktop.
Go Code Coverage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MIN_COVER=67.5 | |
go test ./... -coverprofile cover.out | |
CODE_COVER=$( go tool cover -func=cover.out | tail -1 | sed '/^$/d;s/[[:blank:]]//g' | sed 's/total:(statements)//g' | sed 's/%//g' ) | |
rm -rf cover.out | |
if [[ "${CODE_COVER}" < "${MIN_COVER}" ]] | |
then | |
echo "*** CODE COVERAGE CHECK FAILED, EXEPECTED ${MIN_COVER}%, GOT ${CODE_COVER}% ***" | |
exit 1 | |
fi | |
echo "*** CODE COVERAGE PASSED AT: ${CODE_COVER}% ***" | |
go vet ./... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment