Watch for source code coverage growth
We are lazy, getting older, forget thing and sometimes hate unit tests :-) This tool aimed to help us not to forget improve code coverage for a new functionality we add.
istanbul-coverage-warden
is supposed to be executed during pull request build and during main branch build. Main brach build should use copy
command to expose gathered code coverage staticstics to S3 bucket for later use.
Pull request builder shoud use check
command, and specify branch it build against. check
command then download main branch code coverage metrics and check against current code coverage. If any source code file has lower LineRate
than main branch, it exit with non-zero code and fail pull request build.
istanbul-coverage-warden copy \
-d my-project-codecoverage-check \
-b master \
-f ./cobertura-coverage.xml
istanbul-coverage-warden check \
-d my-project-codecoverage-check \
-b master \
-f ./cobertura-coverage.xml
Pull request build job should provide branch name your PR made agains. For Jenkins Github Pull Request plugin you might use ghprbTargetBranch
parameter.
Then check for return codes:
- 0 - Success
- 1 - Coverage dropped, build should fail
- 2 - File open error (might be first build)
If you have ready binarry, just copy it to Jenkins. It should not require any dependencies. If you need to build it, follow the following steps:
https://golang.org/doc/install
go get -u github.com/yury-sannikov/istanbul-coverage-warden
It should download and build binary