Created
December 5, 2013 19:14
-
-
Save wadey/7811454 to your computer and use it in GitHub Desktop.
Makefile for generating Go coverage reports for Jenkins (for projects containing multiple packages)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GO=$(firstword $(subst :, ,$(GOPATH))) | |
GOCOV=$(GO)/bin/gocov | |
GOCOVXML=$(GO)/bin/gocov-xml | |
# List of pkgs for the project | |
PKGS=$(shell go list ./...) | |
# Coverage output: coverage/$PKG/coverage.out | |
COVPKGS=$(addsuffix /coverage.out,$(addprefix coverage/,$(PKGS))) | |
jenkins: coverage/cobertura-coverage.xml | |
coverage/cobertura-coverage.xml: coverage/all.out $(GOCOV) $(GOCOVXML) | |
$(GOCOV) convert $< | $(GOCOVXML) >$@ | |
coverage/all.out: $(COVPKGS) | |
echo "mode: set" >$@ | |
grep -hv "mode: set" $(wildcard $^) >>$@ | |
$(COVPKGS): .FORCE | |
@ mkdir -p $(dir $@) | |
@ go test -coverprofile $@ $(patsubst coverage/%/coverage.out,%,$@) | |
$(GOCOV): | |
go get github.com/axw/gocov/gocov | |
$(GOCOVXML): | |
go get github.com/AlekSi/gocov-xml | |
.FORCE: | |
.PHONY: jenkins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment