forked from kubevela/kubevela
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
237 lines (195 loc) · 6.78 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# Vela version
VELA_VERSION ?= master
# Repo info
GIT_COMMIT ?= git-$(shell git rev-parse --short HEAD)
GIT_COMMIT_LONG ?= $(shell git rev-parse HEAD)
VELA_VERSION_VAR := github.com/oam-dev/kubevela/version.VelaVersion
VELA_GITVERSION_VAR := github.com/oam-dev/kubevela/version.GitRevision
LDFLAGS ?= "-X $(VELA_VERSION_VAR)=$(VELA_VERSION) -X $(VELA_GITVERSION_VAR)=$(GIT_COMMIT)"
GOX = go run github.com/mitchellh/gox
TARGETS := darwin/amd64 linux/amd64 windows/amd64
DIST_DIRS := find * -type d -exec
TIME_LONG = `date +%Y-%m-%d' '%H:%M:%S`
TIME_SHORT = `date +%H:%M:%S`
TIME = $(TIME_SHORT)
BLUE := $(shell printf "\033[34m")
YELLOW := $(shell printf "\033[33m")
RED := $(shell printf "\033[31m")
GREEN := $(shell printf "\033[32m")
CNone := $(shell printf "\033[0m")
INFO = echo ${TIME} ${BLUE}[ .. ]${CNone}
WARN = echo ${TIME} ${YELLOW}[WARN]${CNone}
ERR = echo ${TIME} ${RED}[FAIL]${CNone}
OK = echo ${TIME} ${GREEN}[ OK ]${CNone}
FAIL = (echo ${TIME} ${RED}[FAIL]${CNone} && false)
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
all: build
# Run tests
test: vet lint
go test -race -coverprofile=coverage.txt -covermode=atomic ./pkg/... ./cmd/...
@$(OK) unit-tests pass
# Build manager binary
build: fmt vet lint
go run hack/chart/generate.go
go build -o bin/vela -ldflags ${LDFLAGS} cmd/vela/main.go
git checkout cmd/vela/fake/chart_source.go
@$(OK) build succeed
vela-cli:
go run hack/chart/generate.go
go build -o bin/vela -ldflags ${LDFLAGS} cmd/vela/main.go
git checkout cmd/vela/fake/chart_source.go
dashboard-build:
cd dashboard && yarn build && cd ./..
dashboard-install:
cd dashboard && yarn && cd ./..
doc-gen:
rm -r docs/en/cli/*
go run hack/docgen/gen.go
go run hack/references/generate.go
api-gen:
swag init -g pkg/server/route.go --output pkg/server/docs
swagger-codegen generate -l html2 -i pkg/server/docs/swagger.yaml -o pkg/server/docs
mv pkg/server/docs/index.html docs/en/developers/references/restful-api/
generate-source:
go run hack/frontend/source.go
cross-build:
go run hack/chart/generate.go
GO111MODULE=on CGO_ENABLED=0 $(GOX) -ldflags $(LDFLAGS) -parallel=3 -output="_bin/{{.OS}}-{{.Arch}}/vela" -osarch='$(TARGETS)' ./cmd/vela/
compress:
( \
echo "\n## Release Info\nVERSION: $(VELA_VERSION)" >> README.md && \
echo "GIT_COMMIT: $(GIT_COMMIT_LONG)\n" >> README.md && \
cd _bin && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf vela-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r vela-{}.zip {} \; && \
sha256sum vela-* > sha256sums.txt \
)
# Run against the configured Kubernetes cluster in ~/.kube/config
run: fmt vet
go run ./cmd/core/main.go
# Run go fmt against code
fmt: goimports installcue
go fmt ./...
$(GOIMPORTS) -local github.com/oam-dev/kubevela -w ./pkg ./cmd
$(CUE) fmt ./hack/vela-templates/cue/*
# Run go vet against code
vet:
go vet ./...
lint: golangci
$(GOLANGCILINT) run ./...
reviewable: manifests fmt vet lint
go mod tidy
# Execute auto-gen code commands and ensure branch is clean.
check-diff: reviewable
git diff --quiet || ($(ERR) please run 'make reviewable' to include all changes && false)
@$(OK) branch is clean
# Build the docker image
docker-build:
docker build --build-arg=VERSION=$(VELA_VERSION) --build-arg=GITVERSION=$(GIT_COMMIT) . -t ${IMG}
# Push the docker image
docker-push:
docker push ${IMG}
e2e-setup:
bin/vela install --image-pull-policy IfNotPresent --image-repo vela-core-test --image-tag $(GIT_COMMIT)
ginkgo version
ginkgo -v -r e2e/setup
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=vela-core,app.kubernetes.io/instance=kubevela -n vela-system --timeout=600s
bin/vela dashboard &
e2e-test:
# Run e2e test
ginkgo -v -skipPackage capability,setup,apiserver -r e2e
ginkgo -v ./test/e2e-test
# integration test will clean environment, please don't put test behind it.
CGO_ENABLED=0 go test -timeout 1h -count=1 -v -tags 'integration' ./test/integration
@$(OK) tests pass
e2e-api-test:
# Run e2e test
ginkgo -v -r e2e/apiserver
e2e-cleanup:
# Clean up
rm -rf ~/.vela
# load docker image to the kind cluster
kind-load:
docker build -t vela-core-test:$(GIT_COMMIT) .
kind load docker-image vela-core-test:$(GIT_COMMIT) || { echo >&2 "kind not installed or error loading image: $(IMAGE)"; exit 1; }
# Image URL to use all building/pushing image targets
IMG ?= vela-core:latest
# Run tests
core-test: fmt vet manifests
go test ./pkg/... -coverprofile cover.out
# Build manager binary
manager: fmt vet lint manifests
go build -o bin/manager ./cmd/core/main.go
# Run against the configured Kubernetes cluster in ~/.kube/config
core-run: fmt vet manifests
go run ./cmd/core/main.go
# Install CRDs and Definitions of Vela Core into a cluster, this is for develop convenient.
core-install: manifests
kubectl apply -f hack/namespace.yaml
kubectl apply -f charts/vela-core/crds/
kubectl apply -f charts/vela-core/templates/defwithtemplate/
kubectl apply -f charts/vela-core/templates/definitions/
kubectl apply -f charts/vela-core/templates/velaConfig.yaml
bin/vela workloads
@$(OK) install succeed
# Uninstall CRDs and Definitions of Vela Core from a cluster, this is for develop convenient.
core-uninstall: manifests
kubectl delete -f charts/vela-core/templates/definitions/
kubectl delete -f charts/vela-core/templates/defwithtemplate/
kubectl delete -f charts/vela-core/crds/
# Generate manifests e.g. CRD, RBAC etc.
manifests:
go generate $(foreach t,pkg apis,./$(t)/...)
./hack/vela-templates/gen_definitions.sh
GOLANGCILINT_VERSION ?= v1.29.0
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
HOSTARCH := $(shell uname -m)
ifeq ($(HOSTARCH),x86_64)
HOSTARCH := amd64
endif
golangci:
ifeq (, $(shell which golangci-lint))
@{ \
set -e ;\
echo 'installing golangci-lint-$(GOLANGCILINT_VERSION)' ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) $(GOLANGCILINT_VERSION) ;\
echo 'Install succeed' ;\
}
GOLANGCILINT=$(GOBIN)/golangci-lint
else
GOLANGCILINT=$(shell which golangci-lint)
endif
.PHONY: goimports
goimports:
ifeq (, $(shell which goimports))
@{ \
set -e ;\
GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports ;\
}
GOIMPORTS=$(GOBIN)/goimports
else
GOIMPORTS=$(shell which goimports)
endif
.PHONY: installcue
installcue:
ifeq (, $(shell which cue))
@{ \
set -e ;\
GO111MODULE=off go get -u cuelang.org/go/cmd/cue ;\
}
CUE=$(GOBIN)/cue
else
CUE=$(shell which cue)
endif
start-dashboard:
go run pkg/server/main/startAPIServer.go &
cd dashboard && yarn && yarn start && cd ..
swagger-gen:
$(GOBIN)/swag init -g server/route.go -d pkg/ -o pkg/server/docs/