forked from intel/afxdp-plugins-for-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
190 lines (167 loc) · 4.59 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
# Copyright(c) 2022 Intel Corporation.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
excluded_from_utests = "/test/e2e|/test/fuzz"
.PHONY: all e2e
all: format build test static
format:
@echo "****** Go Format ******"
@echo
-go fmt github.com/intel/afxdp-plugins-for-kubernetes/...
@echo
@echo
@echo "****** Clang Format ******"
@echo
-clang-format -i -style=file internal/bpf/*.c internal/bpf/*.h
@echo
@echo
buildc:
@echo "****** Build BPF ******"
@echo
gcc ./internal/bpf/bpfWrapper.c -lbpf -c -o ./internal/bpf/bpfWrapper.o
ar rs ./internal/bpf/libwrapper.a ./internal/bpf/bpfWrapper.o &> /dev/null
@echo
@echo
builddp: buildc
@echo "****** Build DP ******"
@echo
go build -o ./bin/afxdp-dp ./cmd/deviceplugin
@echo
@echo
buildcni: buildc
@echo "****** Build CNI ******"
@echo
go build -o ./bin/afxdp ./cmd/cni
@echo
@echo
build: builddp buildcni
docker:
@echo "****** Docker Image ******"
@echo
docker build -t afxdp-device-plugin -f images/amd64.dockerfile .
@echo
@echo
podman:
@echo "****** Podman Image ******"
@echo
podman build -t afxdp-device-plugin -f images/amd64.dockerfile .
@echo
@echo
image:
if $(MAKE) podman; then \
echo "Podman build succeeded"; \
else \
echo "Podman build failed, trying docker.."; \
$(MAKE) docker; \
fi
undeploy:
@echo "****** Stop Daemonset ******"
@echo
kubectl delete -f ./deployments/daemonset.yml --ignore-not-found=true
@echo
@echo
deploy: image undeploy
@echo "****** Deploy Daemonset ******"
@echo
kubectl create -f ./deployments/daemonset.yml
@echo
@echo
test: buildc
@echo "****** Unit Tests ******"
@echo
go test $(shell go list ./... | grep -vE $(excluded_from_utests) | grep -v "/internal/resourcesapi")
@echo
@echo
e2e: build
@echo "****** Basic E2E ******"
@echo
cd test/e2e/ && ./e2e-test.sh
@echo
@echo
e2efull: build
@echo "****** Full E2E ******"
@echo
cd test/e2e/ && ./e2e-test.sh --full
@echo
@echo
e2edaemon: image
@echo "****** E2E Daemonset ******"
@echo
cd test/e2e/ && ./e2e-test.sh --daemonset
@echo
@echo
e2efulldaemon: image
@echo "****** Full E2E DaemSet ******"
@echo
cd test/e2e/ && ./e2e-test.sh --full --daemonset
@echo
@echo
# static-ci: consists of static analysis tools required for the public CI
# repository workflow /.github/workflows/public-ci.yml
# Note: the public repository CI comprises of further static analysis tools via the
# superlinter job: golangci-lint, hadolint, clang-format and shellcheck
static-ci:
@echo "****** Verify dependencies ******"
@echo
go mod verify
@echo
@echo
@echo "****** Run staticcheck ******"
@echo
staticcheck ./...
@echo
@echo
@echo "****** Go Vet ******"
@echo
for pkg in $$(go list github.com/intel/afxdp-plugins-for-kubernetes/...); do echo $$pkg && go vet $$pkg; done
@echo
@echo
# static: consists of static analysis tools required for internal CI repository workflows and locally
# run tests. static includes static-ci test module.
static: static-ci
@echo "****** GolangCI-Lint ******"
@echo
golangci-lint run
@echo
@echo
@echo "****** Hadolint ******"
@echo
for file in $$(find . -type f -iname "*dockerfile*" -not -path "./.git/*"); do echo $$file && docker run --rm -i hadolint/hadolint < $$file; done
@echo
@echo
@echo "****** Shellcheck ******"
@echo
for file in $$(find . -iname "*.sh" -not -path "./.git/*"); do echo $$file && shellcheck $$file; done
@echo
@echo
@echo "****** Trivy ******"
@echo
trivy image afxdp-device-plugin --no-progress --format json
trivy fs . --no-progress --format json
@echo
@echo
cloc: format
@echo "****** Update CLOC ******"
@echo
@cloc $(shell git ls-files)
sed -i "/<\!---clocstart--->/,/<\!---clocend--->/c\<\!---clocstart--->\n\`\`\`\n$$(cloc $$(git ls-files) | sed -n '/-----/,$$p' | sed -z 's/\n/\\n/g')\n\`\`\`\n\<\!---clocend--->" README.md
@echo
@echo
clean:
@echo "****** Cleanup ******"
@echo
rm -f ./bin/afxdp
rm -f ./bin/afxdp-dp
rm -f ./internal/bpf/bpfWrapper.o
rm -f ./internal/bpf/libwrapper.a
@echo
@echo