forked from hwameistor/hwameistor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
168 lines (138 loc) · 6.1 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
include Makefile.variables
# local-disk-manager build definitions
LDM_MODULE_NAME = local-disk-manager
LDM_BUILD_INPUT = ${CMDS_DIR}/${LDM_MODULE_NAME}/diskmanager.go
# local-storage build definitions
LS_MODULE_NAME = local-storage
LS_BUILD_INPUT = ${CMDS_DIR}/${LS_MODULE_NAME}/storage.go
# scheduler build definitions
SCHEDULER_MODULE_NAME = scheduler
SCHEDULER_BUILD_INPUT = ${CMDS_DIR}/${SCHEDULER_MODULE_NAME}/scheduler.go
# admission build definitions
ADMISSION_MODULE_NAME = admission
ADMISSION_BUILD_INPUT = ${CMDS_DIR}/${ADMISSION_MODULE_NAME}/admission.go
.PHONY: compile
compile: compile_ldm compile_ls compile_scheduler compile_admission
.PHONY: image
image: build_ldm_image build_ls_image build_scheduler_image build_admission_image
.PHONY: release
release: release_ldm release_ls release_scheduler release_admission
.PHONY: unit-test
unit-test:
go test -race -coverprofile=coverage.txt -covermode=atomic ./pkg/...
curl -s https://codecov.io/bash | bash
.PHONY: vendor
vendor:
go mod tidy -compat=1.17
go mod vendor
.PHONY: release_ldm
release_ldm:
# build for amd64 version
${DOCKER_MAKE_CMD} make compile_ldm
${DOCKER_BUILDX_CMD_AMD64} -t ${LDM_IMAGE_NAME}:${RELEASE_TAG}-amd64 -f ${LDM_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
# build for arm64 version
${DOCKER_MAKE_CMD} make compile_ldm_arm64
${DOCKER_BUILDX_CMD_ARM64} -t ${LDM_IMAGE_NAME}:${RELEASE_TAG}-arm64 -f ${LDM_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
# push to a public registry
${MUILT_ARCH_PUSH_CMD} ${LDM_IMAGE_NAME}:${RELEASE_TAG}
.PHONY: release_ls
release_ls:
# build for amd64 version
${DOCKER_MAKE_CMD} make compile_ls
${DOCKER_BUILDX_CMD_AMD64} -t ${LS_IMAGE_NAME}:${RELEASE_TAG}-amd64 -f ${LS_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
# build for arm64 version
${DOCKER_MAKE_CMD} make compile_ls_arm64
${DOCKER_BUILDX_CMD_ARM64} -t ${LS_IMAGE_NAME}:${RELEASE_TAG}-arm64 -f ${LS_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
# push to a public registry
${MUILT_ARCH_PUSH_CMD} ${LS_IMAGE_NAME}:${RELEASE_TAG}
.PHONY: release_scheduler
release_scheduler:
# build for amd64 version
${DOCKER_MAKE_CMD} make compile_scheduler
${DOCKER_BUILDX_CMD_AMD64} -t ${SCHEDULER_IMAGE_NAME}:${RELEASE_TAG}-amd64 -f ${SCHEDULER_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
# build for arm64 version
${DOCKER_MAKE_CMD} make compile_scheduler_arm64
${DOCKER_BUILDX_CMD_ARM64} -t ${SCHEDULER_IMAGE_NAME}:${RELEASE_TAG}-arm64 -f ${SCHEDULER_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
# push to a public registry
${MUILT_ARCH_PUSH_CMD} ${SCHEDULER_IMAGE_NAME}:${RELEASE_TAG}
.PHONY: release_admission
release_admission:
# build for amd64 version
${DOCKER_MAKE_CMD} make compile_admission
${DOCKER_BUILDX_CMD_AMD64} -t ${ADMISSION_IMAGE_NAME}:${RELEASE_TAG}-amd64 -f ${ADMISSION_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
# build for arm64 version
${DOCKER_MAKE_CMD} make compile_admission_arm64
${DOCKER_BUILDX_CMD_ARM64} -t ${ADMISSION_IMAGE_NAME}:${RELEASE_TAG}-arm64 -f ${ADMISSION_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
# push to a public registry
${MUILT_ARCH_PUSH_CMD} ${ADMISSION_IMAGE_NAME}:${RELEASE_TAG}
.PHONY: build_ldm_image
build_ldm_image:
@echo "Build local-disk-manager image ${LDM_IMAGE_NAME}:${IMAGE_TAG}"
${DOCKER_MAKE_CMD} make compile_ldm
docker build -t ${LDM_IMAGE_NAME}:${IMAGE_TAG} -f ${LDM_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
.PHONY: build_ls_image
build_ls_image:
@echo "Build local-storage image ${LS_IMAGE_NAME}:${IMAGE_TAG}"
${DOCKER_MAKE_CMD} make compile_ls
docker build -t ${LS_IMAGE_NAME}:${IMAGE_TAG} -f ${LS_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
.PHONY: build_scheduler_image
build_scheduler_image:
@echo "Build scheduler image ${SCHEDULER_IMAGE_NAME}:${IMAGE_TAG}"
${DOCKER_MAKE_CMD} make compile_scheduler
docker build -t ${SCHEDULER_IMAGE_NAME}:${IMAGE_TAG} -f ${SCHEDULER_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
.PHONY: build_admission_image
build_admission_image:
@echo "Build admission image ${ADMISSION_IMAGE_NAME}:${IMAGE_TAG}"
${DOCKER_MAKE_CMD} make compile_admission
docker build -t ${ADMISSION_IMAGE_NAME}:${IMAGE_TAG} -f ${ADMISSION_IMAGE_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
.PHONY: apis
apis:
${DOCKER_MAKE_CMD} make _gen-apis
.PHONY: builder
builder:
docker build -t ${BUILDER_NAME}:${BUILDER_TAG} -f ${BUILDER_DOCKERFILE} ${PROJECT_SOURCE_CODE_DIR}
docker push ${BUILDER_NAME}:${BUILDER_TAG}
.PHONY: _gen-apis
_gen-apis:
${OPERATOR_CMD} generate k8s
${OPERATOR_CMD} generate crds
bash hack/update-codegen.sh
.PHONY: compile_ldm
compile_ldm:
GOARCH=amd64 ${BUILD_ENVS} ${BUILD_CMD} ${BUILD_OPTIONS} -o ${LDM_BUILD_OUTPUT} ${LDM_BUILD_INPUT}
.PHONY: compile_ldm_arm64
compile_ldm_arm64:
GOARCH=arm64 ${BUILD_ENVS} ${BUILD_CMD} ${BUILD_OPTIONS} -o ${LDM_BUILD_OUTPUT} ${LDM_BUILD_INPUT}
.PHONY: compile_ls
compile_ls:
GOARCH=amd64 ${BUILD_ENVS} ${BUILD_CMD} ${BUILD_OPTIONS} -o ${LS_BUILD_OUTPUT} ${LS_BUILD_INPUT}
.PHONY: compile_ls_arm64
compile_ls_arm64:
GOARCH=arm64 ${BUILD_ENVS} ${BUILD_CMD} ${BUILD_OPTIONS} -o ${LS_BUILD_OUTPUT} ${LS_BUILD_INPUT}
.PHONY: compile_scheduler
compile_scheduler:
GOARCH=amd64 ${BUILD_ENVS} ${BUILD_CMD} ${BUILD_OPTIONS} -o ${SCHEDULER_BUILD_OUTPUT} ${SCHEDULER_BUILD_INPUT}
.PHONY: compile_scheduler_arm64
compile_scheduler_arm64:
GOARCH=arm64 ${BUILD_ENVS} ${BUILD_CMD} ${BUILD_OPTIONS} -o ${SCHEDULER_BUILD_OUTPUT} ${SCHEDULER_BUILD_INPUT}
.PHONY: compile_admission
compile_admission:
GOARCH=amd64 ${BUILD_ENVS} ${BUILD_CMD} ${BUILD_OPTIONS} -o ${ADMISSION_BUILD_OUTPUT} ${ADMISSION_BUILD_INPUT}
.PHONY: compile_admission_arm64
compile_admission_arm64:
GOARCH=arm64 ${BUILD_ENVS} ${BUILD_CMD} ${BUILD_OPTIONS} -o ${ADMISSION_BUILD_OUTPUT} ${ADMISSION_BUILD_INPUT}
.PHONY: _enable_buildx
_enable_buildx:
@echo "Checking if buildx enabled"
@if [[ "$(shell docker version -f '{{.Server.Experimental}}')" == "true" ]]; \
then \
docker buildx inspect mutil-platform-builder &>/dev/null; \
[ $$? == 0 ] && echo "ok" && exit 0; \
docker buildx create --name mutil-platform-builder &>/dev/null&& echo "ok" && exit 0; \
else \
echo "experimental config of docker is false"; \
exit 1; \
fi
.PHONY: e2e-test
e2e-test:
bash test/e2e-test.sh