File tree Expand file tree Collapse file tree 2 files changed +36
-7
lines changed
Expand file tree Collapse file tree 2 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ include:
1111 file :
1212 - ' go-standart-steps.yml'
1313
14- # cache:
15- # paths:
16- # - /apt-cache
17- # - /go/src/github.com
18- # - /go/src/golang.org
19- # - /go/src/google.golang.org
20- # - /go/src/gopkg.in
14+ cache :
15+ paths :
16+ - /apt-cache
17+ - /go/src/github.com
18+ - /go/src/golang.org
19+ - /go/src/google.golang.org
20+ - /go/src/gopkg.in
2121
2222stages :
2323 - test
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ #
3+ # Code coverage generation
4+
5+ COVERAGE_DIR=" ${COVERAGE_DIR:- coverage} "
6+ PKG_LIST=$( go list ./... | grep -v /vendor/)
7+
8+ # Create the coverage files directory
9+ mkdir -p " $COVERAGE_DIR " ;
10+
11+ # Create a coverage file for each package
12+ for package in ${PKG_LIST} ; do
13+ go test -covermode=count -coverprofile " ${COVERAGE_DIR} /${package##*/ } .cov" " $package " ;
14+ done ;
15+
16+ # Merge the coverage profile files
17+ echo ' mode: count' > " ${COVERAGE_DIR} " /coverage.cov ;
18+ tail -q -n +2 " ${COVERAGE_DIR} " /* .cov >> " ${COVERAGE_DIR} " /coverage.cov ;
19+
20+ # Display the global code coverage
21+ go tool cover -func=" ${COVERAGE_DIR} " /coverage.cov ;
22+
23+ # If needed, generate HTML report
24+ if [ " $1 " == " html" ]; then
25+ go tool cover -html=" ${COVERAGE_DIR} " /coverage.cov -o coverage.html ;
26+ fi
27+
28+ # Remove the coverage files directory
29+ rm -rf " $COVERAGE_DIR " ;
You can’t perform that action at this time.
0 commit comments