forked from kubevela/kubevela
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
146 lines (117 loc) · 4.22 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
include makefiles/const.mk
include makefiles/dependency.mk
include makefiles/release.mk
include makefiles/develop.mk
include makefiles/build.mk
include makefiles/e2e.mk
.DEFAULT_GOAL := all
all: build
# ==============================================================================
# Targets
## test: Run tests
test: unit-test-core test-cli-gen
@$(OK) unit-tests pass
## test-cli-gen: Run the unit tests for cli gen
test-cli-gen:
@mkdir -p ./bin/doc
@go run ./hack/docgen/cli/gen.go ./bin/doc
## unit-test-core: Run the unit tests for core
unit-test-core:
go test -coverprofile=coverage.txt $(shell go list ./pkg/... ./cmd/... ./apis/... | grep -v apiserver | grep -v applicationconfiguration)
go test $(shell go list ./references/... | grep -v apiserver)
## build: Build vela cli binary
build: vela-cli kubectl-vela
@$(OK) build succeed
## build-cli: Clean build
build-cleanup:
@echo "===========> Cleaning all build output"
@rm -rf _bin
## fmt: Run go fmt against code
fmt: goimports installcue
go fmt ./...
$(GOIMPORTS) -local github.com/oam-dev/kubevela -w $$(go list -f {{.Dir}} ./...)
$(CUE) fmt ./vela-templates/definitions/internal/*
$(CUE) fmt ./vela-templates/definitions/deprecated/*
$(CUE) fmt ./vela-templates/definitions/registry/*
$(CUE) fmt ./pkg/stdlib/pkgs/*
$(CUE) fmt ./pkg/stdlib/op.cue
$(CUE) fmt ./pkg/workflow/tasks/template/static/*
## sdk_fmt: Run go fmt against code
sdk_fmt:
./hack/sdk/reviewable.sh
## vet: Run go vet against code
vet:
@$(INFO) go vet
@go vet $(shell go list ./...|grep -v scaffold)
## staticcheck: Run the staticcheck
staticcheck: staticchecktool
@$(INFO) staticcheck
@$(STATICCHECK) $(shell go list ./...|grep -v scaffold)
## lint: Run the golangci-lint
lint: golangci
@$(INFO) lint
@$(GOLANGCILINT) run --fix --verbose --skip-dirs 'scaffold'
## reviewable: Run the reviewable
reviewable: manifests fmt vet lint staticcheck helm-doc-gen sdk_fmt
go mod tidy
# check-diff: Execute auto-gen code commands and ensure branch is clean.
check-diff: reviewable
git --no-pager diff
git diff --quiet || ($(ERR) please run 'make reviewable' to include all changes && false)
@$(OK) branch is clean
## docker-push: Push the docker image
docker-push:
@echo "===========> Pushing docker image"
@docker push $(VELA_CORE_IMAGE)
## image-cleanup: Delete Docker images
image-cleanup:
ifneq (, $(shell which docker))
# Delete Docker images
ifneq ($(shell docker images -q $(VELA_CORE_TEST_IMAGE)),)
docker rmi -f $(VELA_CORE_TEST_IMAGE)
endif
endif
## image-load: load docker image to the kind cluster
image-load:
docker build -t $(VELA_CORE_TEST_IMAGE) -f Dockerfile.e2e .
kind load docker-image $(VELA_CORE_TEST_IMAGE) || { echo >&2 "kind not installed or error loading image: $(VELA_CORE_TEST_IMAGE)"; exit 1; }
## core-test: Run tests
core-test:
go test ./pkg/... -coverprofile cover.out
## manager: Build vela core manager binary
manager:
$(GOBUILD_ENV) go build -o bin/manager -a -ldflags $(LDFLAGS) ./cmd/core/main.go
## manifests: Generate manifests e.g. CRD, RBAC etc.
manifests: installcue kustomize
go generate $(foreach t,pkg apis,./$(t)/...)
# TODO(yangsoon): kustomize will merge all CRD into a whole file, it may not work if we want patch more than one CRD in this way
$(KUSTOMIZE) build config/crd -o config/crd/base/core.oam.dev_applications.yaml
./hack/crd/cleanup.sh
go run ./hack/crd/dispatch/dispatch.go config/crd/base charts/vela-core/crds
rm -f config/crd/base/*
./vela-templates/gen_definitions.sh
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
HOSTARCH := $(shell uname -m)
ifeq ($(HOSTARCH),x86_64)
HOSTARCH := amd64
endif
## check-license-header: Check license header
check-license-header:
./hack/licence/header-check.sh
## def-gen: Install definitions
def-install:
./hack/utils/installdefinition.sh
## helm-doc-gen: Generate helm chart README.md
helm-doc-gen: helmdoc
readme-generator -v charts/vela-core/values.yaml -r charts/vela-core/README.md
## help: Display help information
help: Makefile
@echo ""
@echo "Usage:"
@echo ""
@echo " make [target]"
@echo ""
@echo "Targets:"
@echo ""
@awk -F ':|##' '/^[^\.%\t][^\t]*:.*##/{printf " \033[36m%-20s\033[0m %s\n", $$1, $$NF}' $(MAKEFILE_LIST) | sort
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'