-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
49 lines (38 loc) · 1017 Bytes
/
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
.PHONY: all build clean download get-build-deps vet lint test cover
include ./vars.mk
all:
@$(MAKE) get-build-deps
@$(MAKE) download
@$(MAKE) vet
@$(MAKE) lint
@$(MAKE) cover
@$(MAKE) build
build/%:
@echo "Building GOARCH=$(*F)"
@GOARCH=$(*F) go build -ldflags=$(LDFLAGS) -o $(BUILD_DIR)/api-mock ./cmd/api-mock
@echo "*** Binary created under $(BUILD_DIR)/api-mock ***"
build: build/amd64
clean:
@rm -rf $(BUILD_DIR)
download:
$(GO_MOD) download
get-build-deps:
@echo "+ Downloading build dependencies"
@go install golang.org/x/tools/cmd/goimports@latest
@go install honnef.co/go/tools/cmd/staticcheck@latest
vet:
@echo "+ Vet"
@go vet ./...
lint:
@echo "+ Linting package"
@staticcheck ./...
$(call fmtcheck, .)
test:
@echo "+ Testing package"
$(GO_TEST) ./...
cover: test
@echo "+ Tests Coverage"
@mkdir -p $(BUILD_DIR)
@touch $(BUILD_DIR)/cover.out
@go test -coverprofile=$(BUILD_DIR)/cover.out ./...
@go tool cover -html=$(BUILD_DIR)/cover.out -o=$(BUILD_DIR)/coverage.html