Skip to content

Commit

Permalink
fix: add make integration command that merges coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Dara Hayes committed Feb 22, 2018
1 parent 62ba301 commit 0fa5084
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
- run: go get github.com/mattn/goveralls
- run: go get -u github.com/golang/dep/cmd/dep
- run: dep ensure
- run: make test-integration
- run: /go/bin/goveralls -service=circle-ci -repotoken=$COVERALLS_TOKEN
- run: make test-integration-cover
- run: /go/bin/goveralls -coverprofile=coverage-all.out -service=circle-ci -repotoken=$COVERALLS_TOKEN
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor/
.idea/
metrics
dist/
dist/
coverage*.out
20 changes: 16 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
PKG = github.com/aerogear/aerogear-metrics-api
TOP_SRC_DIRS = pkg
PACKAGES ?= $(shell sh -c "find $(TOP_SRC_DIRS) -name \\*_test.go \
-exec dirname {} \\; | sort | uniq")
BIN_DIR := $(GOPATH)/bin
SHELL = /bin/bash
BINARY = metrics

LDFLAGS=-ldflags "-w -s -X main.Version=$(TAG)"
LDFLAGS=-ldflags "-w -s -X main.Version=${TAG}"

.PHONY: setup
setup:
Expand All @@ -23,12 +26,21 @@ build_binary:
.PHONY: test-unit
test-unit:
@echo Running tests:
go test -v -race -coverpkg=./... ./...
go test -v -race -cover $(UNIT_TEST_FLAGS) \
$(addprefix $(PKG)/,$(PACKAGES))

.PHONY: test-integration
test-integration:
@echo Running tests:
go test -v -race -tags=integration -coverpkg=./... ./...
go test -v -race -cover $(UNIT_TEST_FLAGS) -tags=integration \
$(addprefix $(PKG)/,$(PACKAGES))

.PHONY: test-integration-cover
test-integration-cover:
echo "mode: count" > coverage-all.out
$(foreach pkg,$(PACKAGES),\
go test -tags=integration -coverprofile=coverage.out -covermode=count $(addprefix $(PKG)/,$(pkg));\
tail -n +2 coverage.out >> coverage-all.out;)

.PHONY: errcheck
errcheck:
Expand All @@ -47,7 +59,7 @@ fmt:

.PHONY: clean
clean:
-rm -f $(BINARY)
-rm -f ${BINARY}

.PHONY: release
release: setup
Expand Down

0 comments on commit 0fa5084

Please sign in to comment.