Skip to content

Commit 0d67d93

Browse files
committed
Feat: Script for Coverage check #22
- Added script for CI for test coverage Signed-off-by: Tanryberdu <tanryberdi@gmail.com> See #22
1 parent 9728d69 commit 0d67d93

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,18 @@ jobs:
1616
uses: actions/checkout@v3.3.0
1717
- name: Unit Tests
1818
run: go test -v -race ./...
19+
- name: Quality Gate - Test coverage shall be above threshold
20+
env:
21+
TESTCOVERAGE_THRESHOLD: 75
22+
run: |
23+
echo "Quality Gate: checking test coverage is above threshold ..."
24+
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
25+
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
26+
echo "Current test coverage : $totalCoverage %"
27+
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
28+
echo "OK"
29+
else
30+
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
31+
echo "Failed"
32+
exit 1
33+
fi

0 commit comments

Comments
 (0)