forked from vaguecoder/gorilla-mux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Script for Coverage check vaguecoder#22
- Added script for CI for test coverage Signed-off-by: Tanryberdu <[email protected]> See vaguecoder#22
- Loading branch information
1 parent
9728d69
commit 0d67d93
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,18 @@ jobs: | |
uses: actions/[email protected] | ||
- name: Unit Tests | ||
run: go test -v -race ./... | ||
- name: Quality Gate - Test coverage shall be above threshold | ||
env: | ||
TESTCOVERAGE_THRESHOLD: 75 | ||
run: | | ||
echo "Quality Gate: checking test coverage is above threshold ..." | ||
echo "Threshold : $TESTCOVERAGE_THRESHOLD %" | ||
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'` | ||
echo "Current test coverage : $totalCoverage %" | ||
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then | ||
echo "OK" | ||
else | ||
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value." | ||
echo "Failed" | ||
exit 1 | ||
fi |