Skip to content
Snippets Groups Projects
Unverified Commit 4f475c0c authored by Daniel Czerwonk's avatar Daniel Czerwonk Committed by GitHub
Browse files

Merge pull request #56 from bio-routing/q3k/really-fix-coverage

Really Fix Coverage
parents 934e4a2c 8ac4a70f
Branches
Tags
No related merge requests found
......@@ -22,8 +22,7 @@ script:
- mkdir -p $HOME/gopath/src/github.com/bio-routing/
- ln -s $TRAVIS_BUILD_DIR $HOME/gopath/src/github.com/bio-routing/bio-rd || true
- cp .bazelrc.travis .bazelrc
- bazel build //vendor/github.com/mattn/goveralls
- bazel test //...
- bazel coverage //...
- bazel-bin/vendor/github.com/mattn/goveralls/linux_amd64_stripped/goveralls -coverprofile=$(find bazel-testlogs/ -name coverage.dat | paste -sd "," -)
- bazel build //vendor/github.com/q3k/goveralls
- bazel-bin/vendor/github.com/q3k/goveralls/linux_amd64_stripped/goveralls -coverprofile=$(find bazel-testlogs/ -iname coverage.dat -or -iname baseline_coverage.dat | paste -sd ',') -merge=false
......@@ -46,7 +46,7 @@
"gps/internal/pb",
"gps/paths",
"gps/pkgtree",
"internal/fs"
"internal/fs",
]
revision = "37d9ea0ac16f0e0a05afc3b60e1ac8c364b6c329"
version = "v0.4.1"
......@@ -63,12 +63,6 @@
revision = "8b28145dffc87104e66d074f62ea8080edfad7c8"
version = "v0.3.0"
[[projects]]
name = "github.com/mattn/goveralls"
packages = ["."]
revision = "b71a1e4855f87991aff01c2c833a75a07059c61c"
version = "v0.0.2"
[[projects]]
branch = "master"
name = "github.com/nightlyone/lockfile"
......@@ -93,6 +87,12 @@
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
version = "v1.0.0"
[[projects]]
name = "github.com/q3k/goveralls"
packages = ["."]
revision = "789b29cb81d4de953738cec0fbaefa8af2ff4ea2"
version = "v0.1.0"
[[projects]]
branch = "master"
name = "github.com/sdboyer/constext"
......@@ -140,7 +140,7 @@
name = "golang.org/x/sys"
packages = [
"unix",
"windows"
"windows",
]
revision = "bb9c189858d91f42db229b04d45a4c3d23a7662a"
......@@ -153,6 +153,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "54ddfce69bb4724edb07fa628b5a6ae7a4fb1af7ba00b2a64fe043d967d2fdff"
inputs-digest = "8d26786e7bd681598d376675bc030c802da70ac1e285fe39220d11970e1036c4"
solver-name = "gps-cdcl"
solver-version = 1
......@@ -19,7 +19,7 @@
# name = "github.com/x/y"
# version = "2.4.0"
required = ["github.com/golang/dep", "github.com/mattn/goveralls", "github.com/go-yaml/yaml"]
required = ["github.com/golang/dep", "github.com/q3k/goveralls", "github.com/go-yaml/yaml"]
[prune]
go-tests = true
......
......@@ -40,7 +40,7 @@ Update vendor/dependencies
After updating Gopkg.toml, run
bazel build //vendor/github.com/golang/dep/cmd/dep
bazel-bin/vendor/github.com/golang/dep/cmd/dep/linux_amd64_stripped/dep
bazel-bin/vendor/github.com/golang/dep/cmd/dep/linux_amd64_stripped/dep use
# hack: dep of dep gives us these, and it breaks gazelle
rm -rf vendor/github.com/golang/dep/cmd/dep/testdata
rm -rf vendor/github.com/golang/dep/internal/fs/testdata/symlinks/dir-symlink
......@@ -7,8 +7,8 @@ go_library(
"gocover.go",
"goveralls.go",
],
importmap = "vendor/github.com/mattn/goveralls",
importpath = "github.com/mattn/goveralls",
importmap = "vendor/github.com/q3k/goveralls",
importpath = "github.com/q3k/goveralls",
visibility = ["//visibility:private"],
deps = ["//vendor/golang.org/x/tools/cover:go_default_library"],
)
......
......@@ -137,6 +137,40 @@ test:
For more information, See https://coveralls.zendesk.com/hc/en-us/articles/201342809-Go
## Semaphore
Store your Coveralls API token in `Environment Variables`:
```
COVERALLS_TOKEN=your_token_goes_here
```
More instructions on how to do this can be found in the [Semaphore documentation](https://semaphoreci.com/docs/exporting-environment-variables.html).
Replace the `go test` line in your `Commands` with these lines:
```
$ go get github.com/mattn/goveralls
$ goveralls -service semaphore
```
`goveralls` automatically use the environment variable `COVERALLS_TOKEN` as the
default value for `-repotoken`.
You can use the `-v` flag to see verbose output from the test suite:
```
$ goveralls -v -service semaphore
```
## Coveralls Enterprise
If you are using Coveralls Enterprise and have a self-signed certificate, you need to skip certificate verification:
```shell
$ goveralls -insecure
```
# Authors
* Yasuhiro Matsumoto (a.k.a. mattn)
......
......@@ -15,6 +15,7 @@ import (
"io/ioutil"
"log"
"path/filepath"
"sort"
"strings"
"golang.org/x/tools/cover"
......@@ -63,6 +64,33 @@ func mergeProfs(pfss [][]*cover.Profile) []*cover.Profile {
return ret
}
// joinProfs merges profiles for different target packages.
func joinProfs(pfss [][]*cover.Profile) []*cover.Profile {
// skip empty profiles ([no test files])
for i := 0; i < len(pfss); i++ {
if len(pfss[i]) > 0 {
pfss = pfss[i:]
break
}
}
if len(pfss) == 0 {
return nil
} else if len(pfss) == 1 {
return pfss[0]
}
ret := []*cover.Profile{}
for _, profiles := range pfss {
for _, profile := range profiles {
ret = append(ret, profile)
}
}
sort.Slice(ret, func(i, j int) bool {
return ret[i].FileName < ret[j].FileName
})
return ret
}
func mergeProfBlocks(as, bs []cover.ProfileBlock) []cover.ProfileBlock {
if len(as) != len(bs) {
log.Fatal("Two block length should be same")
......@@ -122,10 +150,19 @@ func parseCover(fn string) ([]*SourceFile, error) {
pfss = append(pfss, profs)
}
sourceFiles, err := toSF(mergeProfs(pfss))
if err != nil {
return nil, err
}
if *merge {
sourceFiles, err := toSF(mergeProfs(pfss))
if err != nil {
return nil, err
}
return sourceFiles, nil
} else {
sourceFiles, err := toSF(joinProfs(pfss))
if err != nil {
return nil, err
}
return sourceFiles, nil
return sourceFiles, nil
}
}
......@@ -8,6 +8,7 @@ package main
import (
"bytes"
_ "crypto/sha512"
"crypto/tls"
"encoding/json"
"errors"
"flag"
......@@ -54,6 +55,9 @@ var (
service = flag.String("service", "travis-ci", "The CI service or other environment in which the test suite was run. ")
shallow = flag.Bool("shallow", false, "Shallow coveralls internal server errors")
ignore = flag.String("ignore", "", "Comma separated files to ignore")
insecure = flag.Bool("insecure", false, "Set insecure to skip verification of certificates")
show = flag.Bool("show", false, "Show which package is being tested")
merge = flag.Bool("merge", true, "Merge multiple coverage profiles into one")
)
// usage supplants package flag's Usage variable
......@@ -149,6 +153,9 @@ func getCoverage() ([]*SourceFile, error) {
args = append(args, line)
cmd.Args = args
if *show {
fmt.Println("goveralls:", line)
}
err = cmd.Run()
if err != nil {
return nil, fmt.Errorf("%v: %v", err, outBuf.String())
......@@ -224,6 +231,13 @@ func process() error {
}
os.Setenv("PATH", strings.Join(paths, string(filepath.ListSeparator)))
//
// Handle certificate verification configuration
//
if *insecure {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}
//
// Initialize Job
//
......@@ -234,6 +248,10 @@ func process() error {
jobId = circleCiJobId
} else if appveyorJobId := os.Getenv("APPVEYOR_JOB_ID"); appveyorJobId != "" {
jobId = appveyorJobId
} else if semaphoreJobId := os.Getenv("SEMAPHORE_BUILD_NUMBER"); semaphoreJobId != "" {
jobId = semaphoreJobId
} else if jenkinsJobId := os.Getenv("BUILD_NUMBER"); jenkinsJobId != "" {
jobId = jenkinsJobId
}
if *repotoken == "" {
......@@ -250,6 +268,8 @@ func process() error {
pullRequest = regexp.MustCompile(`[0-9]+$`).FindString(prURL)
} else if prNumber := os.Getenv("APPVEYOR_PULL_REQUEST_NUMBER"); prNumber != "" {
pullRequest = prNumber
} else if prNumber := os.Getenv("PULL_REQUEST_NUMBER"); prNumber != "" {
pullRequest = prNumber
}
sourceFiles, err := getCoverage()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment