File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 15
15
- name : Checkout Code
16
16
17
17
- name : Unit Tests
18
- run : go test -v -race ./...
18
+ run : |
19
+ sudo go test ./... -coverprofile coverage.out -covermode count
20
+ sudo go tool cover -func coverage.out
21
+ - name : Quality Gate - Test coverage shall be above threshold
22
+ env :
23
+ TESTCOVERAGE_THRESHOLD : 75
24
+ run : |
25
+ echo "Quality Gate: checking test coverage is above threshold ..."
26
+ echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
27
+ totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
28
+ echo "Current test coverage : $totalCoverage %"
29
+ if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
30
+ echo "OK"
31
+ else
32
+ echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
33
+ echo "Failed"
34
+ exit 1
35
+ fi
Original file line number Diff line number Diff line change 5
5
test :
6
6
@echo " Testing ..."
7
7
@go clean -testcache
8
- @go test -v -race -coverprofile cover .out ./...
9
- @go tool cover -func=cover .out
8
+ @go test -v -race -coverprofile coverage .out ./...
9
+ @go tool cover -func=coverage .out
You can’t perform that action at this time.
0 commit comments