This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
forked from edwinfrc/voucher
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
82 lines (65 loc) · 1.61 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
# Go parameters
GOCMD=go
GORELEASER=goreleaser
GOLANGCI-LINT=golangci-lint
DOCKER=docker
GOPATH?=`echo $$GOPATH`
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
PACKAGES := voucher_server voucher_client
CODE=./cmd/
SERVER_NAME=voucher_server
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 \
$(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
go tool cover -html=coverage.txt
test:
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
lint:
golangci-lint run
lint-new:
golangci-lint run --new-from-rev master
clean:
$(GOCLEAN)
@for PACKAGE in $(PACKAGES); do \
rm -vrf build/$$PACKAGE; \
done
ensure-deps:
$(GOCMD) mod tidy
$(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_server:
$(GOBUILD) -o build/$(SERVER_NAME) -v $(CODE)$(SERVER_NAME)
container:
$(DOCKER) build -t $(IMAGE_NAME) .
release:
$(GORELEASER)
snapshot:
$(GORELEASER) --snapshot