-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
53 lines (38 loc) · 1002 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
50
51
COMPONENT_NAME:=canned
DOCKER_TAG=$(COMPONENT_NAME)
GO111MODULE=on
export GO111MODULE
GOFLAGS+=-mod=vendor
export GOFLAGS
LDFLAGS=-ldflags "-w -s"
.PHONY: all build docker format lint vendor clean
all: build
build:
$(info Building $(COMPONENT_NAME))
@go build ${LDFLAGS} -o ${COMPONENT_NAME}
docker: build
$(info Builder docker image for $(COMPONENT_NAME))
@docker build . -t $(DOCKER_TAG)
docker_install:
$(info Installing $(COMPONENT_NAME))
@CGO_ENABLED=0 go install ${LDFLAGS}
test:
$(info Performing tests)
@go test -v -cover .
coverage:
$(info Performing coverage)
@go test -coverprofile=coverage.out && go tool cover -func=coverage.out && go tool cover -html=coverage.out
format:
$(info Formatting code)
go fmt ./...
lint:
$(info Performing static analysis)
@golint .
vendor:
@$(info Updating vendored modules)
@go mod tidy && go mod vendor
clean:
$(info Cleaning $(COMPONENT_NAME))
@$(RM) ${COMPONENT_NAME}
$(info Removing test artifacts...)
@$(RM) coverage.*