Skip to content

Commit 551d499

Browse files
committed
Add Makefile and fix linter
1 parent 5f21fc2 commit 551d499

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
SOURCE_DIRS = handler leader predicate status
2+
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
5+
.DEFAULT_GOAL := build
6+
7+
# ensure: ## Install or update project dependencies
8+
# @dep ensure
9+
10+
build: $(SOURCES) ## Build Test
11+
go build -i -ldflags="-s -w" ./...
12+
13+
lint: ## Run golint
14+
@golint -set_exit_status $(addsuffix /... , $(SOURCE_DIRS))
15+
16+
fmt: ## Run go fmt
17+
@gofmt -d $(SOURCES)
18+
19+
fmtcheck: ## Check go formatting
20+
@gofmt -l $(SOURCES) | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi
21+
22+
test: ## Run unit tests
23+
@go test -cover $(addprefix ./, $(addsuffix /... , $(SOURCE_DIRS)))
24+
25+
vet: ## Run go vet
26+
@go vet $(addprefix ./, $(SOURCE_DIRS))
27+
28+
coverage-all.out: $(PACKAGES)
29+
@grep -q -F 'mode: count' coverage-all.out || sed -i '1i mode: count' coverage-all.out
30+
31+
$(PACKAGES): $(SOURCES)
32+
@go test -coverprofile=coverage.out -covermode=count $@ && tail -n +2 coverage.out >> coverage-all.out;
33+
34+
test-coverage-html: coverage-all.out ## Check out the test coverage locally
35+
@go tool cover -html=coverage-all.out
36+
37+
ci-test-coverage: coverage-all.out ## CI test coverage, upload to coveralls
38+
@goveralls -coverprofile=coverage-all.out -service $(COVERAGE_SVC)
39+
40+
check: fmtcheck vet lint build test ## Pre-flight checks before creating PR
41+
42+
clean: ## Clean up your working environment
43+
@rm -f coverage-all.out coverage.out
44+
45+
# generate: ## regenerate mocks
46+
# go get github.com/vektra/mockery/.../
47+
# @go generate ./...
48+
49+
help: ## Show this help screen
50+
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
51+
@echo ''
52+
@echo 'Available targets are:'
53+
@echo ''
54+
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
55+
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
56+
57+
.PHONY: ensure build lint fmt fmtcheck test vet check help test-coverage-html clean $(PACKAGES)

status/conditions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func TestConditionsGetNotExists(t *testing.T) {
160160
}
161161

162162
func TestConditionsRemoveFromNilConditions(t *testing.T) {
163-
var conditions *Conditions = nil
163+
var conditions *Conditions
164164
assert.False(t, conditions.RemoveCondition(ConditionType("C")))
165165
}
166166

0 commit comments

Comments
 (0)