schrej / godacov Goto Github PK
View Code? Open in Web Editor NEWCommand-line tool for publishing go test coverage reports to Codacy
License: Apache License 2.0
Command-line tool for publishing go test coverage reports to Codacy
License: Apache License 2.0
Hi,
I just started using codacy for this project and I've encountered a panic. Travis reports the following:
panic: Invalid line format
goroutine 1 [running]:
github.com/schrej/godacov/cmd.run(0x958180, 0xc42012a180, 0x0, 0x6)
/home/travis/gopath/src/github.com/schrej/godacov/cmd/root.go:81 +0x615
github.com/spf13/cobra.(*Command).execute(0x958180, 0xc4200a8010, 0x6, 0x6, 0x958180, 0xc4200a8010)
/home/travis/gopath/src/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/spf13/cobra.(*Command).ExecuteC(0x958180, 0x6c7294, 0xc420136200, 0x95bd50)
/home/travis/gopath/src/github.com/spf13/cobra/command.go:852 +0x30a
github.com/spf13/cobra.(*Command).Execute(0x958180, 0xc42007c058, 0x0)
/home/travis/gopath/src/github.com/spf13/cobra/command.go:800 +0x2b
github.com/schrej/godacov/cmd.Execute()
/home/travis/gopath/src/github.com/schrej/godacov/cmd/root.go:49 +0x2d
main.main()
/home/travis/gopath/src/github.com/schrej/godacov/main.go:19 +0x20
Here is my coverage script:
#!/usr/bin/env bash
set -e
echo "" > coverage.txt
for d in $(go list ./... | grep -v vendor); do
go test -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
This is my travis configuration:
sudo: required
language: go
go:
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- tip
matrix:
allow_failures:
- go: tip
services:
- docker
install:
- go get github.com/Masterminds/glide
- go get github.com/schrej/godacov
script:
- glide install
- ./configs/coverage.sh
after_success:
- bash <(curl -s https://codecov.io/bash)
- godacov -t $CODACY_PROJECT_TOKEN -r ./coverage.txt -c $TRAVIS_COMMIT
If coverage file has 2 entries like this :
vendor_health.go:59.143,62.16 3 0
vendor_health.go:59.143,62.16 3 1
totalNumStatements is calculated as 6 rather than 3.
Hence the coverage reported is 50% of actual.
We've observed that using -outputdir
to aggregate coverage data can lead to multiple mode: atomic
statements at the head of the final coverage profile. Rather than simply skipping the first line, would recommend detecting and ignoring any such lines.
Also, the len(lines)-1
ignores the last line of likely useful data, no?
It looks like this is related to codacy/codacy-coverage-reporter#11
I was trying to upload a coverage file with the following command and got the error Failed to post: {"error":"not found"}
. It looks like this is related to codacy/codacy-coverage-reporter#11.
godacov -t xxxx -r ./cover.out -c xxx
Any ideas?
It looks like this is related to the custom base url, for example the java client supports an environment variable called CODACY_API_BASE_URL
that allows you to override the base url
The said errors are here:
go get github.com/schrej/godacov ✓ 20:13:04
# github.com/spf13/cobra
../../spf13/cobra/command.go:457:12: fs.ShorthandLookup undefined (type *pflag.FlagSet has no field or method ShorthandLookup)
../../spf13/cobra/command.go:1314:10: c.lflags.SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
../../spf13/cobra/command.go:1314:32: c.Flags().SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
../../spf13/cobra/command.go:1492:18: c.parentsPflags.SortFlags undefined (type *pflag.FlagSet has no field or method SortFlags)
If the file name contains a -
it is trimmed by the regex and wrong file name is used.
Example :
FileName= "abcd-pkg/a.go"
After parsing the filename used to report coverage will be pkg/a.go
.
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.