mattn / goveralls Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
It does not work without COVERALLS_TOKEN or -repotoken
Print JSON to stdout and exit: https://github.com/mattn/goveralls/blob/master/goveralls.go#L224
May be broken after d70c8b3
See log: https://travis-ci.org/msoap/go-carpet/jobs/116232465
This fixed by:
diff --git a/goveralls.go b/goveralls.go
index 9bc02de..39f6235 100644
--- a/goveralls.go
+++ b/goveralls.go
@@ -220,11 +220,6 @@ func process() error {
return err
}
- if repotoken == nil {
- fmt.Println(string(b))
- return nil
- }
-
params := make(url.Values)
params.Set("json", string(b))
res, err := http.PostForm(*endpoint+"/api/v1/jobs", params)
Hi!
I just started getting travis failures that look like so:
$ $HOME/gopath/bin/goveralls -service=travis-ci
signal: killed: warning: no packages being tested depend on github.com/hhrutter/pdfcpu/cmd/pdfcpu
warning: no packages being tested depend on github.com/hhrutter/pdfcpu/create
The command "$HOME/gopath/bin/goveralls -service=travis-ci" exited with 1.
My travis build used to work and my local go test ./... also works.
My local environment is: go version go1.9.3 darwin/amd64
What am I missing here?
A very common pattern is:
if err := doSomething(); err != nil {
return err
}
If return err
is uncovered, it also reports if err := doSomething(); err != nil {
as uncovered even if that statement is in fact covered by a test. This over counts the number of uncovered statements by 1 for each if-return-err block.
My project requires -tags ("go test -tags ....") to run the tests. Is there a way to pass it?
I'm trying to integrate coveralls for my project littledot/mockhiato#10 However, I am getting the following error on Travis.
$ $HOME/gopath/bin/goveralls -service=travis-ci
08:33:53 gocover.go:58: Profile FileName is different
This is reproducible locally as well. Do you know what causes this error?
I've a number of sub-packages in a folder. Running goveralls executes the tests, fails if they fail with output and outputs to coveralls.io when run on Travis. However the -v
flag does not produce verbose output:
When finish the build,got :
goveralls.go:135: invalid character '<' looking for beginning of value.
the build is :https://drone.io/github.com/hanguofeng/ipquery/11
Would you please help to see this.
a/dummy_test.go
package main
import "testing"
func TestDummy(t *testing.T) {
}
a/main.go
package main
import (
"fmt"
)
type foo struct {
bar string
}
func main() {
var f foo
f.bar = "a"
fmt.Println(f.bar)
}
b/dummy_test.go
package main
import "testing"
func TestDummy(t *testing.T) {
}
b/main.go
package main
import "fmt"
func main() {
fmt.Println("b")
}
command and output:
$ goveralls -package ./... INVALID_KEY
ok a 0.002s
ok b 0.003s
15:58:29 goveralls.go:287: How did we get here??
panic: How did we get here??
goroutine 1 [running]:
log.Panic(0x7fed418b4aa8, 0x1, 0x1)
/opt/golang/src/pkg/log/log.go:307 +0xb5
main.main()
/home/ben/go/src/github.com/mattn/goveralls/goveralls.go:287 +0x2983
goroutine 6 [finalizer wait]:
runtime.park(0x410de0, 0x9b9a08, 0x9b7829)
/opt/golang/src/pkg/runtime/proc.c:1334 +0x66
runfinq()
/opt/golang/src/pkg/runtime/mgc0.c:2271 +0x84
runtime.goexit()
/opt/golang/src/pkg/runtime/proc.c:1386
What license (GPL, BSD, etc) is goveralls
released under?
Hello,
I'm trying to use goveralls with travis pro (not the free version) but i always have this error message:
Bad response status from coveralls: 422 - {"message":"Couldn't find a repository matching this job.","error":true}
I checked that the repository exists in coveralls as i got the token from this place.
When i pass -service="" instead of the default value i have no errors but i don't see anything inside coveralls ui.
Hi,
Today my Drone.io builds using goveralls stopped working. You can check the output.
Is it fixable on my side or something broke while implementing changes for Go 1.2 tools support?
Thank you!
I am unable to use this tool with multiple packages
goveralls -package ./... XXXXXXXXXXXX
cannot use test profile flag with multiple packages
error: %v exit status 1
17:58:08 gocov.go:132: Error loading gocov results: exit status 1
How do I exclude specific folders from coverage report ... For example I have a Example Folder with sample go code but dont want it to be used in coverage report %
Case in point my repo https://github.com/julianfrank/gtmesh ... I dont want the examples folder in the coverage % report
Hi,
I need to run my tests with no parallel. I usually do this with
go test ./... -p 1
But I did not find a way to pass this option to goveralls. Tried with env var GOMAXPROCS, COVERALLS_PARALLEL but no success. Is this possible?
Thanks
I want to do go test -short
, not go test
. Instead of some flags being passed on, like -covermode
and -v
, flags starting with test.
should be passed on to the test program. This is what test binaries do as well.
Then you could use -test.short
, -test.v
and such.
Travis CI reports errors for recent commits of my repo: https://github.com/casbin/casbin. One of the error jobs is: https://travis-ci.org/casbin/casbin/jobs/300637769
Worker information
Build system information
removed ‘/etc/apt/sources.list.d/basho_riak.list’
Executing: /tmp/tmp.SVF14ymuRQ/gpg.1.sh --keyserver
hkp://keyserver.ubuntu.com:80
--recv
EA312927
gpg: requesting key EA312927 from hkp server keyserver.ubuntu.com
gpg: key EA312927: "MongoDB 3.2 Release Signing Key <[email protected]>" 1 new signature
gpg: Total number processed: 1
gpg: new signatures: 1
W: http://dl.hhvm.com/ubuntu/dists/trusty/InRelease: Signature by key 36AEF64D0207E7EEE352D4875A16E7281BE7A449 uses weak digest algorithm (SHA1)
W: http://ppa.launchpad.net/couchdb/stable/ubuntu/dists/trusty/Release.gpg: Signature by key 15866BAFD9BCC4F3C1E0DFC7D69548E1C17EAB57 uses weak digest algorithm (SHA1)
git.checkout
0.32s$ git clone --depth=50 --branch=master https://github.com/casbin/casbin.git casbin/casbin
Cloning into 'casbin/casbin'...
$ cd casbin/casbin
$ git checkout -qf ccc3b45b162b04f9a126724c7b8ff935c3c1088e
Updating gimme
Setting environment variables from repository settings
$ export COVERALLS_TOKEN=[secure]
125.42s$ GIMME_OUTPUT="$(gimme tip | tee -a $HOME/.bashrc)" && eval "$GIMME_OUTPUT"
go version devel +d005736213 Sun Nov 12 01:19:40 2017 +0000 linux/amd64
$ export GOPATH=$HOME/gopath
$ export PATH=$HOME/gopath/bin:$PATH
$ mkdir -p $HOME/gopath/src/github.com/casbin/casbin
$ rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/github.com/casbin/casbin/
$ export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/casbin/casbin
$ cd $HOME/gopath/src/github.com/casbin/casbin
0.01s
$ gimme version
v1.2.0
$ go version
go version devel +d005736213 Sun Nov 12 01:19:40 2017 +0000 linux/amd64
go.env
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/travis/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/travis/gopath"
GORACE=""
GOROOT="/home/travis/.gimme/versions/go"
GOTMPDIR=""
GOTOOLDIR="/home/travis/.gimme/versions/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build499874909=/tmp/go-build -gno-record-gcc-switches"
before_install
4.85s$ go get github.com/mattn/goveralls
Using Go 1.5 Vendoring, not checking for Godeps
install
1.12s$ go get -t -v ./...
github.com/Knetic/govaluate (download)
github.com/Knetic/govaluate
github.com/casbin/casbin/config
github.com/casbin/casbin/util
github.com/casbin/casbin/rbac
github.com/casbin/casbin/model
github.com/casbin/casbin/persist
github.com/casbin/casbin/file-adapter
github.com/casbin/casbin
2.60s$ $HOME/gopath/bin/goveralls -service=travis-ci
exit status 2: warning: no packages being tested depend on matches for pattern github.com/casbin/casbin
warning: no packages being tested depend on matches for pattern github.com/casbin/casbin/config
warning: no packages being tested depend on matches for pattern github.com/casbin/casbin/file-adapter
warning: no packages being tested depend on matches for pattern github.com/casbin/casbin/model
warning: no packages being tested depend on matches for pattern github.com/casbin/casbin/persist
# github.com/casbin/casbin/rbac (testmain)
/tmp/go-build082606531/b001/_testmain.go:69:74: undefined: util.GoCover_0
FAIL github.com/casbin/casbin/rbac [build failed]
The command "$HOME/gopath/bin/goveralls -service=travis-ci" exited with 1.
Done. Your build exited with 1.
Starting from this commit, Travis CI starts to report error. I only changed README.md in that commit. All following commits report the same error. See: https://github.com/casbin/casbin/commits/master
Can you help me? Thanks!
Are there any plans to add https://www.jetbrains.com/teamcity/ to the list of supported services? Or is there any workaround to make it work on TeamCity?
Hi @mattn,
A very nice little tool.
I am using the -ignore
flag to exclude all my gomock generated code from code coverage. When I run
goveralls -package=./pkg/... -ignore=$(find -name generated_mock*.go -printf "%P\n" | paste -d, -s)
it does ignore my files.
When I run
goveralls -package=./pkg/... -ignore=$(find -name generated_mock*.go | paste -d, -s)
it does not.
The difference is, that in the first example, I am removing the leading ./
from my find
results. In the second example, I don't.
So passing in ./pkg/generated_mock.go
would fail, whereas pkg/generated_mock.go
would not.
After getting a build set up on Travis-CI (see my .travis.yml), I finally got goveralls
working (seemingly), but the results posted to coveralls.io seem very incomplete. Here is my most recent Travis-CI log: https://travis-ci.org/aggieben/trello/jobs/20551786#L90, which indicates the coverage job: https://coveralls.io/jobs/1381003.
The coverage job not only doesn't indicate any coverage stats (although otherwise appears to be valid), but it doesn't show up in my dashboard at all.
What's going on here?
The instructions are somewhat confusing when talking about travis on the main page, so I decided to try them out. In any case, the 5-line after-script on https://github.com/wfreeman/cq/blob/master/.travis.yml
was enough to get it working.
Thanks!
Hi!, looking to use this for a project and wondering if you could make a release or tag :) thanks
Hi,
I made a PR to gRPC-Go (grpc/grpc-go#363) to enable test coverage. I got the following error on Travis. It seems due to gRPC-GO uses an alias google.golang.org/grpc. Can you help take a look?
0.04s$ goveralls -package="google.golang.org/grpc"
can't load package: package github.com/grpc/grpc-go: code in directory /home/travis/gopath/src/github.com/grpc/grpc-go expects import "google.golang.org/grpc"
error: exit status 1
22:07:04 gocov.go:134: Error loading gocov results: exit status 1
The command "goveralls -package="google.golang.org/grpc"" exited with 1.
Done. Your build exited with 1.
Hello I am using goveralls and seeing the following error:
go build somerepo/cmd/apid/tests: no non-test Go files in go/src/somerepo/cmd/apid/tests
FAIL somerepo/cmd/apid/config [build failed]
I believe the issue is the tests
directory
The coverage of blang/semver dropped between two builds because the last build suddenly included a separate subdirectory (examples).
Is that a new semantic of goveralls?
Relevant:
Coveralls Status Page
Build that suddenly included subdirectory # 31
Previous build, directory not included # 30
Drone.io build settings:
go get
go build
go get github.com/axw/gocov/gocov
go get github.com/mattn/goveralls
goveralls -service drone.io -repotoken $COVERALLS_TOKEN
cd examples
go build
Hi @mattn, we're rolling out branch coverage support for Coveralls.io and have landed it in two other integration libraries:
Node: nickmerwin/node-coveralls@d571dac
Python: TheKevJames/coveralls-python#145
There are more details about the new branches
parameter here:
https://coveralls.zendesk.com/hc/en-us/articles/201350799-API-Reference
I wanted to get it on your radar now in case you or another maintainer has spare time to add this support to goveralls.
Thank you!
Please take a look at golang/go#12513 - it probably makes sense to remove -race or change used -covermode.
I spent far too long to understand why my reports to Coveralls.io was not showing any branch info, commit message, etc. My app is built with Docker, and it was excluding .git
folder in my .dockerignore
file. This resulted with missing formdata POST to coveralls.io.
Easily fixed by just including .git
folder to my Docker container.
Steps to reproduce:
mvdan/sh
at this commit: mvdan/sh@24105a8goveralls
(latest version) inside the root of the repoexit status 1: warning: no packages being tested depend on github.com/mvdan/sh/cmd/gosh
warning: no packages being tested depend on github.com/mvdan/sh/interp
/tmp/go-build510370213/github.com/mvdan/sh/cmd/shfmt/_test/shfmt.test flag redefined: p
panic: /tmp/go-build510370213/github.com/mvdan/sh/cmd/shfmt/_test/shfmt.test flag redefined: p
goroutine 1 [running]:
flag.(*FlagSet).Var(0xc4200480c0, 0x623ae0, 0xc4200127aa, 0x56c48d, 0x1, 0x5738ad, 0x26)
/home/mvdan/tip/src/flag/flag.go:793 +0x415
flag.(*FlagSet).BoolVar(0xc4200480c0, 0xc4200127aa, 0x56c48d, 0x1, 0xc420035e00, 0x5738ad, 0x26)
/home/mvdan/tip/src/flag/flag.go:566 +0x70
flag.(*FlagSet).Bool(0xc4200480c0, 0x56c48d, 0x1, 0x623400, 0x5738ad, 0x26, 0x51b7fc)
/home/mvdan/tip/src/flag/flag.go:579 +0x7f
flag.Bool(0x56c48d, 0x1, 0xc42000a300, 0x5738ad, 0x26, 0xc42000a3a0)
/home/mvdan/tip/src/flag/flag.go:586 +0x5e
github.com/mvdan/sh/cmd/gosh.init()
github.com/mvdan/sh/cmd/gosh/_obj/main.go:16 +0x92
main.init()
<autogenerated>:1 +0x5f
FAIL github.com/mvdan/sh/cmd/shfmt 0.003s
Happens on Travis too: https://travis-ci.org/mvdan/sh/jobs/220619066
Hi, I wonder how to pass specific arguments to my test.
When test is run, it's passed arguments like go test -v -a xxx -b yyy -c zzz
You may recommend using profile like goveralls -coverprofile=coverage.out.
When running goveralls after getting coverage.out by go test, error was shown.
gocover.go:42: Can't find can't find "main.go": cannot find package "command-line-arguments/" in any of:
/usr/local/Cellar/go/1.7/libexec/src/command-line-arguments (from $GOROOT)
Thanks.
Most ironically for a test coverage tool, goveralls
has no tests whatsoever. What is a good strategy for testing it? Here are a few thoughts:
main()
function into smaller components, making it easier to write unit tests for each part.Any thoughts on what is the right approach?
README says "goveralls requires a working Go installation (Go1 or higher)" but looks like it doesn't compatible with go-1.1:
$ goveralls -service=travis-ci
flag provided but not defined: -coverprofile
Usage of /tmp/go-build038197162/github.com/powerman/rpc-codec/jsonrpc2/_test/jsonrpc2.test:
-httptest.serve="": if non-empty, httptest.NewServer serves on this address and blocks
-test.bench="": regular expression to select benchmarks to run
-test.benchmem=false: print memory allocations for benchmarks
-test.benchtime=1s: approximate run time for each benchmark
-test.blockprofile="": write a goroutine blocking profile to the named file after execution
-test.blockprofilerate=1: if >= 0, calls runtime.SetBlockProfileRate()
-test.cpu="": comma-separated list of number of CPUs to use for each test
-test.cpuprofile="": write a cpu profile to the named file during execution
-test.memprofile="": write a memory profile to the named file after execution
-test.memprofilerate=0: if >=0, sets runtime.MemProfileRate
-test.parallel=2: maximum test parallelism
-test.run="": regular expression to select tests and examples to run
-test.short=false: run smaller test suite to save time
-test.timeout=0: if positive, sets an aggregate time limit for all tests
-test.v=false: verbose: print additional output
FAIL github.com/powerman/rpc-codec/jsonrpc2 0.020s
error: exit status 1
10:30:23 gocov.go:137: Error loading gocov results: exit status 1
- go test -v -covermode=count -coverprofile=coverage.out
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
I have been having to use this to get my test results to properly function. It is advertised that this package will handle go test -v
on its own, so I thus tried:
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
This gave a failure because no cover profile was found. Cool, didn't know that it wasn't outputting to that file. So it's trying to read a nonexistent file. The error can be seen on any of the tests found here.
So, after this failure I decided to try:
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -v -service=travis-ci -repotoken $COVERALLS_TOKEN
This also gives a failure, because it's looking for gocov
. gocov
isn't even listed as a requirement to be installed in order for goveralls to be used. Of course I could easily install this, but why would I need to install gocov
when you're already asking us to download the go tool cover
version, which is much better in my opinion. That failure can be found in any of the tests found here.
What's going on here? Is the documentation out of date? Are we supposed to install things that you aren't telling us to install? Like, this is pretty absurd.
Hi everyone,
I've been trying to contribute to and open source project and noticed that the coveralls coverage percent differs from what I get from go tool cover. The difference is relatively small but I thought you still might want to know about it. I think it's entirely caused by goveralls counting braces but go cover not counting them (go cover approach explained here).
Possible solutions (I'd be happy to contribute toward either)
Don't count the braces (which as a downside will make the coveralls.io report looks weird because the first line of functions wouldn't be marked as covered - the same thing of course happens when you use go's html report go tool cover -html=profile.cov
.
Provide a way to output the coverage from goveralls without submitting the report to coveralls.io. Basically add a flag so I can do something like goveralls --report
and get something similar to go tool cover -func=profile.cov.
This would actually be pretty useful because goveralls correctly outputs coverage across multiple packages (by merging the coverage reports) which go cover doesn't - so this could be used for projects not even using coveralls.io.
I'd be happy to submit a PR if you want to go in either direction above.
Here's a contrived example:
(based on this)
//config.go
package config
type Config struct {
data map[string]map[string]string
}
func NewConfig() () {
_ = &Config{
data: make(map[string]map[string]string),
}
}
func (c *Config) parse(fname string) (err error) {
return nil
}
//config_test.go
package config
import (
"testing"
)
func TestGet(t *testing.T) {
NewConfig()
}
Then I run the test like this
go test -covermode=count -coverprofile=profile.cov
And check my coverage like this
go tool cover -func=profile.cov
Which give 50%.
For coveralls I get 62.5%. Here's why:
cat profile.cov
mode: count
github.com/casbin/casbin/config/config.go:8.21,12.2 1 1
github.com/casbin/casbin/config/config.go:14.50,16.2 1 0
Go cover I believe just sees (2) blocks:
block 1: 1/1 lines covered
block 2: 0/1 lines covered
Total = 1/2 = 50%
goveralls gives this output
(https://github.com/mattn/goveralls/blob/master/gocover.go#L102)
1
2
3
4
5
6
7 1
8 1
9 1
10 1
11 1
12
13 0
14 0
15 0
Which means it counts 8 lines (instead of 2 because 6 are braces) and 3 lines without coverage (instead of 1) giving the 5/8 and 62.5%.
Also to be fair - your coverage does match the HTML report (which shows 5/8 lines covered)
go tool cover -html=profile.cov
https://travis-ci.org/MichaelMonashev/sync/jobs/148532887
I think this error rise here: https://github.com/mattn/goveralls/blob/master/goveralls.go#L226 and "shallow" flag don`t hide it.
We're running goveralls in a private drone service, and there's no GIT_BRANCH environment variable, there's only CI_BRANCH (see http://readme.drone.io/usage/variables/).
Using rev-parse doesn't work either because drone checks out the specific commit (CI_COMMIT) before running the tests. Should goveralls look for CI_BRANCH as well? I know that this can open the gate to hell (travis has TRAVIS_BRANCH and circle has CIRCLE_BRANCH), but this is something other coveralls library support:
If that's acceptable, I can send a PR :)
I'm trying to use Goveralls to report on my test coverage but I seem to be getting wildly different coverage values depending on which tool I run and how I run it.
I hope I'm doing something wrong or misunderstanding how to use goveralls and would appreciate some help. Thanks in advance.
go test -coverprofile=cover.out
# removed for brevity
PASS
coverage: 90.2% of statements
ok github.com/NickPresta/gowave/wave 0.409s
90.2% coverage
I also have a cover.out
file in the current directory that allows me to do go tool cover -html=cover.out
and everything looks correct.
gocov test | gocov report
# removed for brevity
github.com/NickPresta/gowave/wave --------------------------- 90.20% (368/408)
90.2% coverage again. Awesome.
$ goveralls skal80cDbbobV3oSWMYAQpnf3Bwsa2WOy
ok github.com/NickPresta/gowave/wave 0.407s
Job #9.1
https://coveralls.io/jobs/933643
goveralls (or Coveralls) seem to think that the coverage percentage is 93.76% which makes no sense.
$ gocov test > out.json
ok github.com/NickPresta/gowave/wave 0.431s
$ goveralls -gocovdata=out.json skal80cDbbobV3oSWMYAQpnf3Bwsa2WOy
Job #11.1
https://coveralls.io/jobs/933646
This still reports that I have 93.76% coverage, which is wrong, despite gocov still thinking it is 90.2%:
$ gocov report out.json
github.com/NickPresta/gowave/wave --------------------------- 90.20% (368/408)
$ goveralls -coverprofile=goveralls.out skal80cDbbobV3oSWMYAQpnf3Bwsa2WOy
Job #14.1
https://coveralls.io/jobs/933650
Goveralls (or Coveralls) seems to think here that I have 79.27% coverage, which is even more strange.
Goveralls version: 2bc52d4d83a9049cc72b50c46042b201e4da93ca
Gocov version: a683f3072f5f857b3cdbb7c19551824a24ca0403
Go version: 1.2
My package: https://github.com/NickPresta/gowave
Also interesting is that the total number of lines seem to fluctuate on Coveralls between runs, which is also incorrect, depending on the source.
Not sure if this is a goveralls or coveralls issue, but I'm always seeing coveralls.io report a travis-ci "push" build as "First build on master X%" instead of showing the code coverage diff. I am seeing code coverage diff for pull-request "PR" builds from travis-ci.
Is this a bad configuration that we can fix on our projects end?
Project: https://github.com/codingsince1985/geo-golang/
Language: Go
CI: Travis-CI
Coveralls Integration: goveralls and gover to aggregate coverage across multiple packages
goveralls -service=travis-ci -coverprofile=gover.coverprofile
https://coveralls.io/github/codingsince1985/geo-golang?branch=master
Maybe related to coveralls: lemurheavy/coveralls-public#610
Hello all.
I used goveralls
to build coverage reports for my repository in Travis-CI and Coveralls, and it worked good right up to the present day (even yesterday).
Unfortunately the latest build failed with an error:
$ $HOME/gopath/bin/goveralls -service=travis-ci ./...
exit status 1: cannot use test profile flag with multiple packages
I assure that everything worked before it and there was no any major changes in the project structure. Thank you for considering my request.
UPD:
I've repaired my CI with the plenty of new tools (along with goveralls
). If anyone run into this issue too, have a look at my .travis.yml
It seems that gover sometimes produces a garbage profile file, and goveralls crashes in a less than friendly manner when this happens:
$ goveralls -coverprofile=gover.coverprofile -service travis-ci
[...]
14:50:43 gocover.go:104: converting profile k8s.io/ingress/controllers/nginx/pkg/template/configmap.go with 113 lines and 113 startline and 113 endline
14:50:43 gocover.go:104: converting profile k8s.io/ingress/controllers/nginx/pkg/template/configmap.go with 113 lines and 113 startline and 113 endline
14:50:43 gocover.go:104: converting profile k8s.io/ingress/controllers/nginx/pkg/template/configmap.go with 113 lines and 113 startline and 113 endline
14:50:43 gocover.go:104: converting profile k8s.io/ingress/controllers/nginx/pkg/template/configmap.go with 113 lines and 113 startline and 113 endline
14:50:43 gocover.go:104: converting profile k8s.io/ingress/controllers/nginx/pkg/template/configmap.go with 113 lines and 116 startline and 118 endline
panic: runtime error: index out of range
goroutine 1 [running]:
panic(0x6e3480, 0xc420012190)
/home/porridge/.gvm/gos/go1.7.3/src/runtime/panic.go:500 +0x1a1
main.toSF(0xc420456000, 0x35, 0x35, 0x35, 0x35, 0x0, 0x0, 0x5340e9)
/home/porridge/Desktop/coding/go/src/github.com/mattn/goveralls/gocover.go:106 +0x71d
main.parseCover(0x7ffcc1379d5b, 0x12, 0x697370, 0x43006c, 0xc4200517f0, 0xc4200517f0, 0x40000000)
/home/porridge/Desktop/coding/go/src/github.com/mattn/goveralls/gocover.go:122 +0x119
main.getCoverage(0x738a3e, 0xf, 0x0, 0x0, 0x0)
/home/porridge/Desktop/coding/go/src/github.com/mattn/goveralls/goveralls.go:114 +0xc3d
main.process(0x0, 0x0)
/home/porridge/Desktop/coding/go/src/github.com/mattn/goveralls/goveralls.go:237 +0x2ea
main.main()
/home/porridge/Desktop/coding/go/src/github.com/mattn/goveralls/goveralls.go:327 +0x26
The above is from goveralls with the following patch:
--- a/gocover.go
+++ b/gocover.go
@@ -100,6 +100,8 @@ func toSF(profs []*cover.Profile) ([]*SourceFile, error) {
}
for _, block := range prof.Blocks {
+ log.Printf("converting profile %s with %d lines and %d startline and %d endline",
+ prof.FileName, len(sf.Coverage), block.StartLine, block.EndLine)
for i := block.StartLine; i <= block.EndLine; i++ {
count, _ := sf.Coverage[i-1].(int)
sf.Coverage[i-1] = count + block.Count
I'm still trying to figure out why gover would produce an invalid coverage (perhaps you have an idea?), but please consider adding some -debug
info to make this easier to figure out.
See kubernetes/ingress-nginx#338 for the background.
Coverage reports don't include directories that have no tests. Let's say there are two .go files in it:
$ go test -cover lib/missing
? lib/missing [no test files]
If we add a single _test.go
file to that package that does nothing, coverage is suddenly reported for all statements in all files in the package (of course, all zeroes).
How can we be sure that a coverage report reflects coverage of ALL packages in a tree, not just those that have at least one test? You think you have such a great coverage until you realize most of your code has no coverage because there are no tests.
One solution is CI failing when a package is discovered with no tests, so you add one. A better solution would be getting coverage output for these packages. Annoyingly, go test
can't be forced to generate a report, and it doesn't return a non-zero error code when there are no tests, so it's unnecessarily hard (like all things in Go...) to automate the detection of packages without tests.
What do people generally do in this situation?
It seems to return the following html error page, but I'm not sure if it is really coveralls in maintenance or a bug, because I cannot find a notice on coveralls's homepage.
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html, body, iframe { margin: 0; padding: 0; height: 100%; }
iframe { display: block; width: 100%; border: none; }
</style>
<title>Application Error</title>
</head>
<body>
<iframe src="https://s3.amazonaws.com/assets.coveralls.io/maintenance.html">
<p>Application Error</p>
</iframe>
</body>
</html>
Add support for https://cloud.google.com/container-builder/docs/
A common pattern is to design an application as a series of reusable and shareable sub-packages within the main repo where your application is essentially just a thin wrapper around these sub-packages.
For a similar example of the idea, consider how golang.org/x/crypto/...
works. There are multiple packages housed under a single repository because they are all related to crypto, however they are intended to be independently used as needed. For example, it's unlikely you would both use bcrypt and scrypt at the same time.
When you have sub-packages in this manner, it is ideal to report the individual test coverage of each package independently. I know it is possible to merge the coverage of multiple packages into a single coverage report as discussed in #20 and, while that makes sense in certain scenarios, it does not make any sense in the scenario I've described.
Is it possible to massage goveralls/coveralls.io to provide individual coverage statistics and badges per sub-package?
I'm getting 100% coverage reported on a project that has subpackages that are insufficiently covered.
Hi Mattn,
goveralls looks like exactly what we need. It is a little unclear to me from the docs and also from my testing whether it is possible to use goveralls to push code coverage stats to coverall.io for a registered open source github repo using a CI system other than Travis or Drone, or one of the other known-about CI systems.
TIA
_Paul
I was able to get goveralls working on travis, but I need to give it a repo_token for a public project.
The Coveralls documentation says repo_token is only needed for private projects:
The option repo_token (found on your repository's page on Coveralls) is used to specify which project on Coveralls your project maps to. This is only needed for private repos and should be kept secret -- anyone could use it to submit coverage data on your repo's behalf.
Hello! I am getting the following issue on travis-ci.org:
5.83s$ goveralls -service=travis-ci -v -package ./pkg/... -repotoken $COVERALLS_TOKEN
08:51:15 gitinfo.go:68: exit status 1: global arguments:
map[--exec-path:<nil> --paginate:false -c:<nil> <command>:log --bare:false --git-dir:<nil> --work-tree:<nil> --help:false --version:false --html-path:false --no-pager:false --no-replace-objects:false <args>:[-1 --pretty=%aN]]
command arguments:
log is not a git command. See 'git help'
The command "goveralls -service=travis-ci -v -package ./pkg/... -repotoken $COVERALLS_TOKEN" exited with 1.
Git is installed in the travis-ci container though:
0.01s$ git log
commit 9aa0e2fbdf223bf1a7abc05ae86f2f221b3036f6
Merge: 91efb8a 8cbe791
Author: Jesus Alvarez <[email protected]>
Date: Mon Apr 17 08:46:58 2017 +0000
Merge 8cbe79127b4440f6c5458bcdde7e64b4960d9125 into 91efb8a00ded54c385f9c3a400e67adf4dcc7ae0
NOTE: I do not have this problem when running locally.
Here is the goveralls comit cloned on travis-ci.org:
$ cd $GOPATH/src/github.com/mattn/goveralls
The command "cd $GOPATH/src/github.com/mattn/goveralls" exited with 0.
0.01s$ git log
commit 42c8a693f7f0977d9e17901324a9dd149a0f71f6
Author: Yasuhiro Matsumoto <[email protected]>
Date: Mon Apr 17 17:53:42 2017 +0900
support multiple coverprofile
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.