Skip to content

Commit 840bb8b

Browse files
author
evombau
committed
fix tools not avalabe
1 parent 6191cd9 commit 840bb8b

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

.gitlab-ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff 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

2222
stages:
2323
- test

tools/coverage.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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";

0 commit comments

Comments
 (0)