This repository was archived by the owner on Jul 28, 2021. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (51 loc) · 2.19 KB
/
Copy pathMakefile
File metadata and controls
65 lines (51 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
REGISTRY ?= docker.io
ORG ?= jmrodri
TAG ?= latest
BROKER_IMAGE ?= $(REGISTRY)/$(ORG)/samplebroker
BUILD_DIR = "${GOPATH}/src/github.com/jmrodri/samplebroker/build"
SOURCE_DIRS = cmd pkg
SOURCES := $(shell find . -name '*.go' -not -path "*/vendor/*")
PACKAGES := $(shell go list ./pkg/...)
COVERAGE_SVC := travis-ci
.DEFAULT_GOAL := build
vendor: ## Install or update project dependencies
@dep ensure
samplebroker: $(SOURCES) ## Build the samplebroker
go build -i -ldflags="-s -w" ./cmd/samplebroker
build: samplebroker ## Build binary from source
@echo > /dev/null
lint: ## Run golint
@golint -set_exit_status $(addsuffix /... , $(SOURCE_DIRS))
fmtcheck: ## Check go formatting
@gofmt -l $(SOURCES) | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi
test: ## Run unit tests
@go test -cover ./pkg/...
coverage-all.out: $(SOURCES)
@echo "mode: count" > coverage-all.out
@$(foreach pkg,$(PACKAGES),\
go test -coverprofile=coverage.out -covermode=count $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
test-coverage-html: coverage-all.out ## checkout the coverage locally of your tests
@go tool cover -html=coverage-all.out
vet: ## Run go vet
@go tool vet ./cmd ./pkg
check: fmtcheck vet lint build test ## Pre-flight checks before creating PR
build-image: ## Build a docker image with the broker binary
env GOOS=linux go build -i -ldflags="-s -s" -o ${BUILD_DIR}/samplebroker ./cmd/samplebroker
docker build -f ${BUILD_DIR}/Dockerfile -t ${BROKER_IMAGE}:${TAG} ${BUILD_DIR}
@echo
@echo "Remember you need to push your image before calling make deploy"
@echo " docker push ${BROKER_IMAGE}:${TAG}"
clean: ## Clean up your working environment
@rm -f samplebroker
@rm -f build/samplebroker
@rm -f coverage-all.out coverage.out handler.out registries.out validation.out
help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo ''
.PHONY: build-image clean lint build fmtcheck test vet help test-coverage-html