-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
104 lines (90 loc) · 4.2 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
#----------------------------------------------------------------------------------
# Build
#----------------------------------------------------------------------------------
# Build dependencies
.PHONY: mod-download
mod-download:
go mod download
DEPSGOBIN=$(shell pwd)/_output/.bin
export GOBIN:=$(DEPSGOBIN)
export PATH:=$(GOBIN):$(PATH)
.PHONY: install-go-tools
install-go-tools: mod-download
mkdir -p $(DEPSGOBIN)
go install github.com/golang/protobuf/[email protected]
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
go install github.com/solo-io/[email protected]
go install github.com/golang/mock/[email protected]
go install github.com/onsi/ginkgo/v2/[email protected]
go install golang.org/x/tools/cmd/goimports
# proto compiler installation
PROTOC_VERSION:=3.15.8
PROTOC_URL:=https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}
.PHONY: install-protoc
install-protoc:
if [ $(shell ${DEPSGOBIN}/protoc --version | grep -c ${PROTOC_VERSION}) -ne 0 ]; then \
echo expected protoc version ${PROTOC_VERSION} already installed ;\
else \
if [ "$(shell uname)" = "Darwin" ]; then \
echo "downloading protoc for osx" ;\
wget $(PROTOC_URL)-osx-x86_64.zip -O $(DEPSGOBIN)/protoc-${PROTOC_VERSION}.zip ;\
elif [ "$(shell uname -m)" = "aarch64" ]; then \
echo "downloading protoc for linux aarch64" ;\
wget $(PROTOC_URL)-linux-aarch_64.zip -O $(DEPSGOBIN)/protoc-${PROTOC_VERSION}.zip ;\
else \
echo "downloading protoc for linux x86-64" ;\
wget $(PROTOC_URL)-linux-x86_64.zip -O $(DEPSGOBIN)/protoc-${PROTOC_VERSION}.zip ;\
fi ;\
unzip $(DEPSGOBIN)/protoc-${PROTOC_VERSION}.zip -d $(DEPSGOBIN)/protoc-${PROTOC_VERSION} ;\
mv $(DEPSGOBIN)/protoc-${PROTOC_VERSION}/bin/protoc $(DEPSGOBIN)/protoc ;\
chmod +x $(DEPSGOBIN)/protoc ;\
rm -rf $(DEPSGOBIN)/protoc-${PROTOC_VERSION} $(DEPSGOBIN)/protoc-${PROTOC_VERSION}.zip ;\
fi
.PHONY: install-tools
install-tools: install-go-tools install-protoc
# Generated Code - Required to update Codgen Templates
.PHONY: generated-code
generated-code: install-tools update-licenses
$(DEPSGOBIN)/protoc --version
go run api/generate.go
# the api/generate.go command is separated out to enable us to run go generate on the generated files (used for mockgen)
# this re-gens test protos
go test ./codegen
go generate -v ./...
$(DEPSGOBIN)/goimports -w .
go mod tidy
#----------------------------------------------------------------------------------
# Test
#----------------------------------------------------------------------------------
# run all tests
# set TEST_PKG to run a specific test package
.PHONY: run-tests
run-tests:
PATH=$(DEPSGOBIN):$$PATH ginkgo -r -failFast -trace -progress \
-progress \
-compilers=4 \
-skipPackage=$(SKIP_PACKAGES) $(TEST_PKG) \
-failOnPending \
-randomizeAllSpecs \
-randomizeSuites \
-keepGoing
$(DEPSGOBIN)/goimports -w .
#----------------------------------------------------------------------------------
# Third Party License Management
#----------------------------------------------------------------------------------
.PHONY: update-licenses
update-licenses:
# check for GPL licenses, if there are any, this will fail
cd ci/oss_compliance; GO111MODULE=on go run oss_compliance.go osagen -c "GNU General Public License v2.0,GNU General Public License v3.0,GNU Lesser General Public License v2.1,GNU Lesser General Public License v3.0,GNU Affero General Public License v3.0"
cd ci/oss_compliance; GO111MODULE=on go run oss_compliance.go osagen -s "Mozilla Public License 2.0,GNU General Public License v2.0,GNU General Public License v3.0,GNU Lesser General Public License v2.1,GNU Lesser General Public License v3.0,GNU Affero General Public License v3.0" > osa_provided.md
cd ci/oss_compliance; GO111MODULE=on go run oss_compliance.go osagen -i "Mozilla Public License 2.0" > osa_included.md
#----------------------------------------------------------------------------------
# Clean
#----------------------------------------------------------------------------------
# Important to clean before pushing new releases. Dockerfiles and binaries may not update properly
.PHONY: clean
clean:
rm -rf codegen/*-packr.go
rm -rf pkg/api
rm -rf vendor_any
rm -rf _output