Skip to content

Commit 7f08070

Browse files
committed
add actions stage to check test coverage level
1 parent c994a8e commit 7f08070

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

.github/workflows/go.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
PKG_CONFIG_PATH: /home/linuxbrew/.linuxbrew/Cellar/libgit2/1.1.1/lib/pkgconfig/
2222
GITCONVEX_TEST_REPO: /home/runner/work/gitconvex-server/gitconvex-test
2323
GITCONVEX_DEFAULT_PATH: /usr/local/gitconvex
24+
COVERAGE_THRESHOLD: 90
2425

2526
steps:
2627
- name: Install libgit2 from Homebrew
@@ -51,6 +52,14 @@ jobs:
5152
export PATH=$PATH:$(go env GOPATH)/bin
5253
make test-ci-pretty
5354
55+
- name: Check Coverage
56+
shell: bash
57+
run: |
58+
export COVERAGE_PERCENT=`go tool cover -func=coverage.out | grep "total:" | grep -Eo '[0-9]+\.[0-9]+'`
59+
echo "Current coverage percentage : $COVERAGE_PERCENT"
60+
make check-coverage
61+
62+
5463
gitconvex-build:
5564
needs:
5665
- gitconvex-test

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ dockerise-test:
7272
docker-compose -f docker-compose.test.yaml build && \
7373
docker-compose -f docker-compose.test.yaml up
7474

75+
check-coverage:
76+
sh ./build_scripts/check_coverage.sh
77+
7578
show-coverage:
7679
go tool cover -html=coverage.out
7780

build_scripts/check_coverage.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
if [[ $COVERAGE_PERCENT < $COVERAGE_THRESHOLD ]];
4+
then
5+
echo "Coverage $COVERAGE_PERCENT is less that the threshold $COVERAGE_THRESHOLD" && exit 1;
6+
else
7+
echo " ✔️ Good work! Coverage $COVERAGE_PERCENT meets the expectation"
8+
fi;

0 commit comments

Comments
 (0)