How to refresh the coverage badge in github README after coverage change

In my project jQuery Terminal I commited a change that make coverage was changed from 79% to 80% (the project is using jasmine, travis and coveralls service) but my badge in README still was showing 79%, even after removing cache. I’ve fixed the issue by adding md5 hash (I know it have been broken, but we don’t use anything secure here) of the spec file after url of my badge, so each time I add something to spec file I’ve get different url, so github wont cache the file.

I’m using make as my build script and I have two README files. Source with .in extension and result with .md extension so I’ve put another variable (I’m already using BRANCH and VERSION in README):

https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=BRANCH&CHECKSUM

and in my Makefile I’ve added:

SPEC_CHECKSUM=`md5sum spec/terminalSpec.js | cut -d' ' -f 1`

README.md: README.in .$(VERSION)
    $(SED) -e "s/{{VER}}/$(VERSION)/g" -e "s/{{BRANCH}}/$(BRANCH)/g" -e "s/{{CHECKSUM}}/$(SPEC_CHECKSUM)/" < README.in > README.md

This is simplification, actually I have more code, you can see in my Makefile

if you have more then one spec file you can use this to generate checksum

SPEC_CHECKSUM=`cat spec/*.js | md5sum | cut -d' ' -f 1`

This will also work if you have different language and different build system.

Advertisements

,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: