Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (107 loc) · 3.66 KB
/
Copy pathMakefile
File metadata and controls
134 lines (107 loc) · 3.66 KB
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
##### Global variables #####
include version.mk Makefile.defs
HAMI_VERSION_PKG=github.com/Project-HAMi/HAMi/pkg
ifndef GITHUB_ACTIONS
REVISION?=$(shell git rev-parse --short HEAD)
else
REVISION=$(GITHUB_SHA)
endif
##### The ldflags for the go build process to set the version related data.
GO_BUILD_LDFLAGS=\
-s \
-w \
-X $(HAMI_VERSION_PKG)/version.version=$(VERSION) \
-X $(HAMI_VERSION_PKG)/device-plugin/nvidiadevice/nvinternal/info.version=$(VERSION) \
-X $(HAMI_VERSION_PKG)/version.revision=$(REVISION) \
-X $(HAMI_VERSION_PKG)/version.buildDate=$(shell date +"%Y%m%d-%T")
all: build
docker:
docker build \
--platform ${TARGET_PLATFORMS} \
--build-arg GOLANG_IMAGE=${GOLANG_IMAGE} \
--build-arg NVIDIA_IMAGE=${NVIDIA_IMAGE} \
--build-arg DEST_DIR=${DEST_DIR} \
--build-arg VERSION=${VERSION} \
--build-arg GOPROXY=https://goproxy.cn,direct \
. -f=docker/Dockerfile -t ${IMG_NAME}:${IMG_TAG}
dockerwithlib:
docker build \
--no-cache \
--platform ${TARGET_PLATFORMS} \
--build-arg GOLANG_IMAGE=${GOLANG_IMAGE} \
--build-arg NVIDIA_IMAGE=${NVIDIA_IMAGE} \
--build-arg DEST_DIR=${DEST_DIR} \
--build-arg VERSION=${VERSION} \
--build-arg GOPROXY=https://goproxy.cn,direct \
. -f=docker/Dockerfile.withlib -t ${IMG_NAME}:${IMG_TAG}
tidy:
$(GO) mod tidy
proto:
$(GO) get github.com/gogo/protobuf/protoc-gen-gofast@v1.3.2
protoc --gofast_out=plugins=grpc:. ./pkg/api/*.proto
build: $(CMDS) $(DEVICES)
$(CMDS):
$(GO) build -ldflags '$(GO_BUILD_LDFLAGS)' -o ${OUTPUT_DIR}/$@ ./cmd/$@
$(DEVICES):
$(GO) build -ldflags '$(GO_BUILD_LDFLAGS)' -o ${OUTPUT_DIR}/$@-device-plugin ./cmd/device-plugin/$@
clean:
$(GO) clean -r -x ./cmd/...
-rm -rf $(OUTPUT_DIR)
.PHONY: all build docker clean test $(CMDS)
test:
mkdir -p ./_output/coverage/
bash hack/unit-test.sh
# Runs every Go benchmark to completion. Set BENCHTIME for a longer, more
# meaningful local measurement, e.g. BENCHTIME=1s make bench.
.PHONY: bench
bench:
bash hack/bench.sh
lint:
bash hack/verify-staticcheck.sh
.PHONY: verify
verify:
hack/verify-all.sh
.PHONY: lint_dockerfile
lint_dockerfile:
@ docker run --rm \
-v $(ROOT_DIR)/.trivyignore:/.trivyignore \
-v /tmp/trivy:/root/trivy.cache/ \
-v $(ROOT_DIR):/tmp/src \
aquasec/trivy:$(TRIVY_VERSION) config --exit-code 1 --severity $(LINT_TRIVY_SEVERITY_LEVEL) /tmp/src/docker ; \
(($$?==0)) || { echo "error, failed to check dockerfile trivy" && exit 1 ; } ; \
echo "dockerfile trivy check: pass"
.PHONY: lint_chart
lint_chart:
@ docker run --rm \
-v $(ROOT_DIR)/.trivyignore:/.trivyignore \
-v /tmp/trivy:/root/trivy.cache/ \
-v $(ROOT_DIR):/tmp/src \
aquasec/trivy:$(TRIVY_VERSION) config --exit-code 1 --severity $(LINT_TRIVY_SEVERITY_LEVEL) /tmp/src/charts ; \
(($$?==0)) || { echo "error, failed to check chart trivy" && exit 1 ; } ; \
echo "chart trivy check: pass"
.PHONY: verify_chart
verify_chart:
$(MAKE) -C charts validate
bash ./hack/verify-chart-version.sh
$(MAKE) lint_chart
.PHONY: e2e-env-setup
e2e-env-setup:
./hack/e2e-test-setup.sh
.PHONY: helm-deploy
helm-deploy:
./hack/deploy-helm.sh "${E2E_TYPE}" "${KUBE_CONF}" "${HAMI_VERSION}"
.PHONY: local-deploy
local-deploy: docker
IMG_NAME="${IMG_NAME}" IMG_TAG="${IMG_TAG}" ./hack/deploy-helm.sh "local" "${KUBE_CONF}"
.PHONY: e2e-test
e2e-test:
./hack/e2e-test.sh "${E2E_TYPE}" "${KUBE_CONF}"
.PHONY: e2e-mig-test
e2e-mig-test:
./hack/e2e-mig-test.sh "${KUBE_CONF}"
.PHONY: e2e-mig-smoke-test
e2e-mig-smoke-test:
./hack/e2e-mig-smoke-test.sh "${KUBE_CONF}"
.PHONY: e2e-policy-test
e2e-policy-test:
HAMI_E2E_REQUIRE_POLICY_TOPOLOGY=true bash ./hack/e2e-policy-test.sh "${KUBE_CONF}"