1build
1build copied to clipboard
Add Code coverage to PR
- Codecov https://codecov.io
@gopinath-langote I'd like to take a go ;) at this one
@amitlevy21 Thanks for picking up.
Let me know if you need any access things for Codecov https://codecov.io.
@gopinath-langote I am testing on a fork, codecov complains that the coverage file is empty. Running the following command:
go test -cover -race --coverprofile=coverage.txt -covermode=atomic ./testing -run .
Yields the following:
ok github.com/gopinath-langote/1build/testing 1.713s coverage: 0.0% of statements
I only found cli_test.go
to be the only file with tests, am I correct? how come it says 0.0% is covered?
Output of coverage.txt:
mode: atomic
The test PR I made on my fork: https://github.com/amitlevy21/1build/pull/1 (has CI logs) The codecov page: https://codecov.io/gh/amitlevy21/1build/commit/6c9f68a8f55aaadc40010ff7b9296118bb20cf41
I only found cli_test.go to be the only file with tests
Yes, That is the only file with test - other files are fixtures to create test data
There are integration tests not unit tests.
So It might not be trivial to get coverage,
Checkout https://www.cyphar.com/blog/post/20170412-golang-integration-coverage
I found a simpler solution by using go test -v -coverpkg ./... ./...
See:
https://travis-ci.org/amitlevy21/1build/jobs/578187996
https://github.com/amitlevy21/1build/pull/1
Can I open a PR?
hello @amitlevy21 Thanks for the effort. unfortunately, the coverage is not correct. Look at codecov generated by your commit: https://codecov.io/gh/amitlevy21/1build/tree/e31f920171fc24b616f12acef34e261b89ebbe7d
I know this is not trivial to get coverage for such binary integration tests.
I'm also trying to figure out the way.
@gopinath-langote So from my understanding, Were seeing the wrong coverage rate because go test doesn't recognize the use of the cli via cobra, right?
I didn't find any issue regarding this in the cobra repository, should I create one?