Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Makefile for generating Go coverage reports for Jenkins (for projects containing multiple packages)
GO=$(firstword $(subst :, ,$(GOPATH)))
# 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 $^) >>$@
@ mkdir -p $(dir $@)
@ go test -coverprofile $@ $(patsubst coverage/%/coverage.out,%,$@)
go get
go get
.PHONY: jenkins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.