-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
89 lines (69 loc) · 1.84 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
VERSION := 0.1.0
COMMIT = $(shell git rev-parse HEAD)
SHA = $(shell git rev-parse --short HEAD)
CURR_DIR = $(shell pwd)
CURR_DIR_WIN = $(shell cd)
BIN_DIR = $(CURR_DIR)/build
BIN_DIR_WIN = $(CURR_DIR_WIN)/build
export GO111MODULE = on
BRANCH := $(shell bash -c 'if [ "$$TRAVIS_PULL_REQUEST" == "false" ]; then echo $$TRAVIS_BRANCH; else echo $$TRAVIS_PULL_REQUEST_BRANCH; fi')
# Set BRANCH when running make manually
ifeq ($(BRANCH),)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
endif
# Setup the -ldflags option to pass vars defined here to app vars
LDFLAGS = -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.branch=${BRANCH}"
PKGS = $(shell go list ./...)
PLATFORMS := windows linux darwin
os = $(word 1, $@)
.PHONY: all
all:
.PHONY: apiserver
apiserver:
ifeq ($(OS),Windows_NT)
cd cmd/apiserver ; go build -o $(BIN_DIR_WIN)/apiserver.exe; cd ..
else
cd cmd/apiserver ; go build -o $(BIN_DIR)/apiserver; cd ..
endif
.PHONY: collector
collector:
ifeq ($(OS),Windows_NT)
cd cmd/collector ; go build -o $(BIN_DIR_WIN)/collector.exe; cd ..
else
cd cmd/collector ; go build -o $(BIN_DIR)/collector; cd ..
endif
.PHONY: lint-ci
lint-ci:
golangci-lint run ./...
.PHONY: lint
lint:
golangci-lint run --timeout=3m ./...
.PHONY: lint-fix
lint-fix:
golangci-lint run --fix
.PHONY: test_collector
test_collector:
go test ./collector/...
.PHONY: test_api
test_api:
go test ./internal/api/...
.PHONY: test_pkg
test_pkg:
go test ./pkg/...
.PHONY: test
test: vet lint test_api test_collector test_pkg
.PHONY: vet
vet:
go vet ./...
.PHONY: dev_up
dev_up: ## start local environment
@echo "RUN dev docker-compose.yml "
docker compose pull
docker compose up --build
.PHONY: ci_up
ci_up: ## start ci environment
@echo "RUN ci docker-compose.yml "
docker compose up --build -d
.PHONY: gogen
gogen: ## generate scalegen
go generate ./...