From 672ac28d8fe0800c9a51ca8decda94ae7fd47326 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sun, 22 Apr 2018 09:17:16 +0800 Subject: [PATCH] chore(coverage): update coverage command. (#354) * chore(coverage): update coverage command. * update Signed-off-by: Bo-Yi Wu --- .drone.yml | 30 +++++++++++++++++++----------- .gitignore | 1 + Makefile | 15 +++++++++++++-- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.drone.yml b/.drone.yml index 42cf2b5..f49185a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,21 +10,21 @@ clone: pipeline: deps: - image: appleboy/golang-testing:1.10.0 + image: golang:1.10.1 group: golang commands: - make deps - make embedmd lint: - image: appleboy/golang-testing:1.10.0 + image: golang:1.10.1 group: golang commands: - make vet - make lint vendor: - image: appleboy/golang-testing:1.10.0 + image: golang:1.10.1 group: golang commands: - make test-vendor @@ -32,50 +32,58 @@ pipeline: - make fmt-check build_linux_amd64: - image: appleboy/golang-testing + image: golang:1.10.1 pull: true group: golang commands: - make build_linux_amd64 build_linux_i386: - image: appleboy/golang-testing:1.10.0 + image: golang:1.10.1 pull: true group: golang commands: - make build_linux_i386 build_linux_arm64: - image: appleboy/golang-testing:1.10.0 + image: golang:1.10.1 pull: true group: golang commands: - make build_linux_arm64 build_linux_arm: - image: appleboy/golang-testing:1.10.0 + image: golang:1.10.1 pull: true group: golang commands: - make build_linux_arm coverage: - image: appleboy/golang-testing:1.10.0 + image: golang:1.10.1 group: golang secrets: [ android_test_token, android_api_key ] commands: - - coverage all + - make unit-test-coverage + + generate-coverage: + image: golang:1.10.1 + pull: true + commands: + - make coverage + when: + event: [ push, pull_request ] codecov: image: robertstettner/drone-codecov secrets: [ codecov_token ] files: - - .cover/coverage.txt + - coverage.all when: event: [ push, pull_request ] release: - image: appleboy/golang-testing:1.10.0 + image: golang:1.10.1 pull: true commands: - make release diff --git a/.gitignore b/.gitignore index 93de03f..68c6718 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ coverage.txt dist custom release +coverage.out diff --git a/Makefile b/Makefile index b275bc9..b1a0c9a 100644 --- a/Makefile +++ b/Makefile @@ -112,8 +112,19 @@ misspell-check: $(MISSPELL) misspell: $(MISSPELL) $(MISSPELL) -w $(GOFILES) -test: fmt-check - for PKG in $(PACKAGES); do $(GO) test -v -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done; +.PHONY: coverage +coverage: + @hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GO) get -u github.com/wadey/gocovmerge; \ + fi + gocovmerge $(shell find . -type f -name "coverage.out") > coverage.all;\ + +.PHONY: unit-test-coverage +unit-test-coverage: init + for PKG in $(PACKAGES); do $(GO) test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done; + +test: init + for PKG in $(PACKAGES); do $(GO) test -v $$PKG || exit 1; done; .PHONY: test-vendor test-vendor: $(GOVENDOR)