Give up on Circle, try Drone
Peter Bourgon
8 years ago
0 | |
profile.cov
|
1 | |
cover.out
|
2 | 0 |
examples/addsvc/addsvc
|
3 | 1 |
examples/addsvc/client/addcli/addcli
|
4 | 2 |
examples/stringsvc1/stringsvc1
|
5 | 3 |
examples/stringsvc2/stringsvc2
|
6 | 4 |
examples/stringsvc3/stringsvc3
|
|
5 |
gover.coverprofile
|
7 | 6 |
|
8 | 7 |
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
9 | 8 |
*.o
|
0 | |
#!/bin/bash
|
1 | |
|
2 | |
set -e
|
3 | |
|
4 | |
echo "mode: count" >| profile.cov
|
5 | |
|
6 | |
for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d);
|
7 | |
do
|
8 | |
if ls $dir/*.go &> /dev/null; then
|
9 | |
go test -covermode=count -coverprofile=$dir/profile.tmp $dir
|
10 | |
if [ -f $dir/profile.tmp ]
|
11 | |
then
|
12 | |
cat $dir/profile.tmp | tail -n +2 >> profile.cov
|
13 | |
rm $dir/profile.tmp
|
14 | |
fi
|
15 | |
fi
|
16 | |
done
|
17 | |
|
18 | |
go tool cover -func profile.cov
|
19 | |
|
20 | |
goveralls -coverprofile=profile.cov -service=circle-ci -repotoken=$COVERALLS_TOKEN
|
21 | |
|
0 | |
test:
|
1 | |
pre:
|
2 | |
- go get github.com/axw/gocov/gocov
|
3 | |
- go get github.com/mattn/goveralls
|
4 | |
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
|
5 | |
override:
|
6 | |
- go get -v -u -d github.com/go-kit/kit/...
|
7 | |
- bin/coverage-circle.bash
|
8 | |
|
1 | 1 |
|
2 | 2 |
# This script runs the cover tool on all packages with test files. If you set a
|
3 | 3 |
# WEB environment variable, it will additionally open the web-based coverage
|
4 | |
# visualizer for each package.
|
|
4 |
# visualizer for each package. If you set a COVERALLS environment variable,
|
|
5 |
# it will report the reults to Coveralls.io.
|
|
6 |
|
|
7 |
set -ex
|
5 | 8 |
|
6 | 9 |
function go_files { find . -name '*_test.go' ; }
|
7 | 10 |
function filter { grep -v '/_' ; }
|
|
18 | 21 |
|
19 | 22 |
PATHS=${1:-$(unique_directories)}
|
20 | 23 |
|
21 | |
function package_names {
|
22 | |
for d in $PATHS
|
|
24 |
function report {
|
|
25 |
for path in $PATHS
|
23 | 26 |
do
|
24 | |
echo github.com/go-kit/kit/$d
|
|
27 |
go test -coverprofile=$path/cover.coverprofile ./$path
|
25 | 28 |
done
|
26 | 29 |
}
|
27 | 30 |
|
28 | |
function report {
|
29 | |
package_names | while read pkg
|
30 | |
do
|
31 | |
go test -coverprofile=cover.out $pkg
|
32 | |
if [ -n "${WEB+x}" ]
|
33 | |
then
|
34 | |
go tool cover -html=cover.out
|
35 | |
fi
|
36 | |
done
|
37 | |
rm cover.out
|
|
31 |
function combine {
|
|
32 |
gover
|
|
33 |
}
|
|
34 |
|
|
35 |
function clean {
|
|
36 |
find . -name cover.coverprofile | xargs rm
|
38 | 37 |
}
|
39 | 38 |
|
40 | 39 |
report
|
|
40 |
combine
|
|
41 |
clean
|
41 | 42 |
|
|
43 |
if [ -n "${WEB+x}" ]
|
|
44 |
then
|
|
45 |
go tool cover -html=$path/cover.coverprofile
|
|
46 |
fi
|
|
47 |
|