-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
84 lines (68 loc) · 3 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
GO ?= go
# read Go version from go,mod file
GO_VERSION := $(shell grep '^go.*$$' go.mod | awk '{print $$2}' | cut -d '.' -f 1,2)
LDFLAGS :=
GOFLAGS :=
BINDIR := $(CURDIR)/bin
# version should match github.com/golang/mock version in go.mod
GOMOCK_VERSION := $(shell grep '^\s*github.com\/golang\/mock\sv\S*$$' go.mod | awk '{print $$2}')
GOMOCK_BINDIR := .mockgen-bin
GOMOCK_BIN := $(GOMOCK_BINDIR)/$(GOMOCK_VERSION)/mockgen
GOLANGCI_LINT_VERSION := v1.60.3
GOLANGCI_LINT_BINDIR := .golangci-bin
GOLANGCI_LINT_BIN := $(GOLANGCI_LINT_BINDIR)/$(GOLANGCI_LINT_VERSION)/golangci-lint
all: build
include versioning.mk
VERSION_LDFLAGS = -X antrea.io/antrea-ui/pkg/version.Version=$(VERSION)
VERSION_LDFLAGS += -X antrea.io/antrea-ui/pkg/version.GitSHA=$(GIT_SHA)
VERSION_LDFLAGS += -X antrea.io/antrea-ui/pkg/version.GitTreeState=$(GIT_TREE_STATE)
VERSION_LDFLAGS += -X antrea.io/antrea-ui/pkg/version.ReleaseStatus=$(RELEASE_STATUS)
LDFLAGS += $(VERSION_LDFLAGS)
.PHONY: bin
bin:
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -ldflags '-s -w $(LDFLAGS)' antrea.io/antrea-ui/...
.PHONY: test
test:
$(GO) test -race -v ./pkg/...
# code linting
$(GOLANGCI_LINT_BIN):
@echo "===> Installing Golangci-lint <==="
@rm -rf $(GOLANGCI_LINT_BINDIR)/* # delete old versions
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOLANGCI_LINT_BINDIR)/$(GOLANGCI_LINT_VERSION) $(GOLANGCI_LINT_VERSION)
.PHONY: golangci
golangci: $(GOLANGCI_LINT_BIN)
@echo "===> Running golangci <==="
@GOOS=linux $(GOLANGCI_LINT_BIN) run -c .golangci.yml
.PHONY: golangci-fix
golangci-fix: $(GOLANGCI_LINT_BIN)
@echo "===> Running golangci-fix <==="
@GOOS=linux $(GOLANGCI_LINT_BIN) run -c .golangci.yml --fix
# mocks
$(GOMOCK_BIN):
@echo "===> Installing mockgen <==="
@rm -rf $(GOMOCK_BINDIR)/* # delete old versions
GOBIN=$(CURDIR)/$(GOMOCK_BINDIR)/$(GOMOCK_VERSION) $(GO) install github.com/golang/mock/mockgen@$(GOMOCK_VERSION)
.PHONY: generate
generate: $(GOMOCK_BIN)
PATH=$(CURDIR)/$(GOMOCK_BINDIR)/$(GOMOCK_VERSION):$$PATH MOCKGEN_COPYRIGHT_FILE=$(CURDIR)/hack/boilerplate/license_header.raw.txt $(GO) generate antrea.io/antrea-ui/...
.PHONY: clean
clean:
rm -rf bin
rm -rf $(GOLANGCI_LINT_BINDIR)
rm -rf $(GOMOCK_BINDIR)
.PHONY: build-frontend
build-frontend:
docker build --pull -t antrea/antrea-ui-frontend:$(DOCKER_IMG_VERSION) -f build/frontend.dockerfile --build-arg GO_VERSION=$(GO_VERSION) .
docker tag antrea/antrea-ui-frontend:$(DOCKER_IMG_VERSION) antrea/antrea-ui-frontend
.PHONY: build-backend
build-backend:
docker build --pull -t antrea/antrea-ui-backend:$(DOCKER_IMG_VERSION) -f build/backend.dockerfile --build-arg GO_VERSION=$(GO_VERSION) .
docker tag antrea/antrea-ui-backend:$(DOCKER_IMG_VERSION) antrea/antrea-ui-backend
.PHONY: build
build: build-frontend build-backend
.PHONY: check-copyright
check-copyright:
@GO=$(GO) $(CURDIR)/hack/add-license.sh
.PHONY: add-copyright
add-copyright:
@GO=$(GO) $(CURDIR)/hack/add-license.sh --add