Skip to content

Commit 4174437

Browse files
committed
Fix coverage output for GH Actions
1 parent e1baef3 commit 4174437

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
vendor*
2-
coverage-all.out
3-
coverage.out
2+
cover.out
43

54
# IDE baggage
6-
.idea/
5+
.idea/

Makefile

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
SOURCE_DIRS = handler leader predicate status
22
SOURCES := $(shell find . -name '*.go' -not -path "*/vendor/*" -not -path "*/.git/*")
3-
PACKAGES := $(shell go list $(addprefix ./, $(addsuffix /... , $(shell ls -d */ | grep -v vendor))))
4-
# COVERAGE_SVC := travis-ci
53
.DEFAULT_GOAL := build
64

75
# ensure: ## Install or update project dependencies
@@ -10,7 +8,7 @@ PACKAGES := $(shell go list $(addprefix ./, $(addsuffix /... , $(shell l
108
build: $(SOURCES) ## Build Test
119
go build -i -ldflags="-s -w" ./...
1210

13-
lint: ## Run golint
11+
lint: golangci-lint ## Run golint
1412
@golangci-lint run --disable-all \
1513
--deadline 5m \
1614
--enable=nakedret \
@@ -38,28 +36,27 @@ fmtcheck: ## Check go formatting
3836
@gofmt -l $(SOURCES) | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi
3937

4038
test: ## Run unit tests
41-
@go test -cover $(addprefix ./, $(addsuffix /... , $(SOURCE_DIRS)))
39+
@go test -race -covermode atomic -coverprofile cover.out $(addprefix ./, $(addsuffix /... , $(SOURCE_DIRS)))
4240

4341
vet: ## Run go vet
4442
@go vet $(addprefix ./, $(SOURCE_DIRS))
4543

46-
coverage-all.out: $(PACKAGES)
47-
@grep -q -F 'mode: count' coverage-all.out || sed -i '1i mode: count' coverage-all.out
48-
49-
$(PACKAGES): $(SOURCES)
50-
@go test -coverprofile=coverage.out -covermode=count $@ && tail -n +2 coverage.out >> coverage-all.out;
51-
52-
test-coverage-html: coverage-all.out ## Check out the test coverage locally
53-
@go tool cover -html=coverage-all.out
54-
55-
ci-test-coverage: coverage-all.out ## CI test coverage, upload to coveralls
56-
@goveralls -coverprofile=coverage-all.out -service $(COVERAGE_SVC)
57-
5844
check: fmtcheck vet lint build test ## Pre-flight checks before creating PR
5945

6046
clean: ## Clean up your working environment
6147
@rm -f coverage-all.out coverage.out
6248

49+
golangci-lint:
50+
ifeq (, $(shell which golangci-lint))
51+
@{ \
52+
set -e ;\
53+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.27.0 ;\
54+
}
55+
GOLANGCI_LINT=$(shell go env GOPATH)/bin/golangci-lint
56+
else
57+
GOLANGCI_LINT=$(shell which golangci-lint)
58+
endif
59+
6360
# generate: ## regenerate mocks
6461
# go get github.com/vektra/mockery/.../
6562
# @go generate ./...
@@ -72,4 +69,4 @@ help: ## Show this help screen
7269
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
7370
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
7471

75-
.PHONY: ensure build lint fmt fmtcheck test vet check help test-coverage-html clean $(PACKAGES)
72+
.PHONY: ensure build lint fmt fmtcheck test vet check help clean

0 commit comments

Comments
 (0)