Skip to content

Commit

Permalink
Feat: Script for Coverage check vaguecoder#22
Browse files Browse the repository at this point in the history
- Added script for CI for test coverage
Signed-off-by: Tanryberdu <[email protected]>

See vaguecoder#22
  • Loading branch information
tanryberdi committed Jan 19, 2023
1 parent 9728d69 commit 0d67d93
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0d67d93

Please sign in to comment.