This will walk you through setting up a test coverage report on coveralls.io which will be updated every time a new build happens on drone.io (a continuous integration server similar to TavisCI).
I’m going to use the couchbaselabs/sg-replicate repo as an example, since it currently does not have any test coverage statistics. The goal is to end up with a badge in the README that points to a test coverage report hosted on coveralls.io.
Clone the repo
Test coverage command line stats
1 2 3
1 2 3 4
Ouch, 69.4% is barely a C-. (if you round up!)
1 2 3 4 5 6
This should open up the following report in your default browser:
- Login to coveralls.io
- Create a new repo
- Get the repo token from the SET UP COVERALLS section
At this point, your empty coveralls repo will look something like this:
Configure Drone.io + Goveralls
If you have not already done so, setup a drone.io build for your repo.
On the drone.io Settings page, make the following changes:
In the Environment Variables section of the web ui, add:
In the commands section, you can replace your existing
go test call with:
1 2 3
Here’s what it should look like:
Kick off a build
Go to the drone.io project page for your repo, and hit Build Now
At the bottom of the build output, you should see:
If you follow the link, you should see something like:
Looks like we just went from a C- to a B! I have no idea why the coverage improved, but I’ll take it.
Add a badge, call it a day
On the coveralls.io project page for your repo, you should see a button near the top called Badge URLS. Click and copy/paste the markdown, which should look something like this:
And add it to your project’s README.