-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMakefile
91 lines (71 loc) · 2.06 KB
/
Makefile
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Go parameters
GOCMD=cd v2 && go
GORELEASER=goreleaser
GOLANGCI-LINT=cd v2 && golangci-lint
DOCKER=docker
GOPATH?=`echo $$GOPATH`
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
PACKAGES := voucher_server voucher_subscriber voucher_client
CODE=./cmd/
SERVER_NAME=voucher_server
SUBSCRIBER_NAME=voucher_subscriber
CLIENT_NAME=voucher_client
IMAGE_NAME?=voucher
export GO111MODULE=on
.PHONY: clean ensure-deps update-deps system-deps \
test show-coverage \
build release snapshot container mocks \
$(PACKAGES)
all: clean ensure-deps build
# System Dependencies
system-deps:
ifeq ($(shell $(GOCMD) version 2> /dev/null) , "")
$(error "go is not installed")
endif
ifeq ($(shell $(DOCKER) -v dot 2> /dev/null) , "")
$(error "docker is not installed")
endif
ifeq ($(shell $(GOLANGCI-LINT) version 2> /dev/null) , "")
$(error "golangci-lint is not installed")
endif
ifeq ($(shell $(GORELEASER) --version dot 2> /dev/null) , "")
$(error "goreleaser is not installed")
endif
$(info "No missing dependencies")
show-coverage: test
$(GOCMD) tool cover -html=coverage.txt
test:
$(GOCMD) test ./... -race -coverprofile=coverage.txt -covermode=atomic
lint:
$(GOLANGCI-LINT) run
lint-new:
$(GOLANGCI-LINT) run --new-from-rev main
clean:
$(GOCLEAN)
@for PACKAGE in $(PACKAGES); do \
rm -vrf build/$$PACKAGE; \
done
ensure-deps:
$(GOCMD) mod download
$(GOCMD) mod verify
update-deps:
$(GOCMD) get -u -t all
$(GOCMD) mod tidy
build: $(PACKAGES)
voucher_client:
$(GOBUILD) -o ../build/$(CLIENT_NAME) -v $(CODE)$(CLIENT_NAME)
voucher_subscriber:
$(GOBUILD) -o ../build/$(SUBSCRIBER_NAME) -v $(CODE)$(SUBSCRIBER_NAME)
voucher_server:
$(GOBUILD) -o ../build/$(SERVER_NAME) -v $(CODE)$(SERVER_NAME)
container:
$(DOCKER) build -t $(IMAGE_NAME) .
release:
$(GORELEASER)
snapshot:
$(GORELEASER) --snapshot
mocks:
mockgen -source=grafeas/grafeas_service.go -destination=grafeas/mocks/grafeas_service_mock.go package=mocks
test-in-docker:
docker run -v $(PWD):/go/src/github.com/grafeas/voucher -w /go/src/github.com/grafeas/voucher -e CGO_ENABLED=0 -it golang:1.15.6-alpine go test ./...