Skip to content

Commit

Permalink
chore: add test coverage threshold
Browse files Browse the repository at this point in the history
Signed-off-by: Dumbledore <mathenge@healthcloud.co.ke>
  • Loading branch information
ageeknamedslickback committed Sep 7, 2021
1 parent 20e7b4c commit e1ba8bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,9 @@ jobs:
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=coverage.out -service=github

- name: Quality Gate - Test coverage shall be above threshold
env:
TESTCOVERAGE_THRESHOLD: 90
run: |
bash scripts/coverage.sh
12 changes: 12 additions & 0 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
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 e1ba8bc

Please sign in to comment.