-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
71 lines (59 loc) · 2.46 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
#----------------------------------------------------------------------------------
# Base
#----------------------------------------------------------------------------------
ROOTDIR := $(shell pwd)
PACKAGE_PATH:=github.com/solo-io/anyvendor
OUTPUT_DIR ?= $(ROOTDIR)/_output
SOURCES := $(shell find . -name "*.go" | grep -v test.go)
VERSION ?= $(shell git describe --tags)
DEPSGOBIN=$(shell pwd)/.bin
#----------------------------------------------------------------------------------
# Repo init
#----------------------------------------------------------------------------------
# https://www.viget.com/articles/two-ways-to-share-git-hooks-with-your-team/
.PHONY: init
init:
git config core.hooksPath .githooks
#----------------------------------------------------------------------------------
# Protobufs
#----------------------------------------------------------------------------------
.PHONY: update-deps
update-deps: mod-download
mkdir -p $(DEPSGOBIN)
PATH=$(DEPSGOBIN):$$PATH go install golang.org/x/tools/cmd/goimports
PATH=$(DEPSGOBIN):$$PATH go install github.com/golang/protobuf/protoc-gen-go
PATH=$(DEPSGOBIN):$$PATH go install github.com/envoyproxy/protoc-gen-validate
PATH=$(DEPSGOBIN):$$PATH go install github.com/envoyproxy/protoc-gen-validate
PATH=$(DEPSGOBIN):$$PATH go get github.com/golang/mock/gomock
PATH=$(DEPSGOBIN):$$PATH go install github.com/golang/mock/mockgen
PATH=$(DEPSGOBIN):$$PATH go install github.com/onsi/ginkgo/v2/[email protected]
.PHONY: mod-download
mod-download: check-go-version
go mod download
#----------------------------------------------------------------------------------
# Generated Code
#----------------------------------------------------------------------------------
.PHONY: generated-code
generated-code: check-go-version $(OUTPUT_DIR)/.generated-code
SUBDIRS:=pkg anyvendor
$(OUTPUT_DIR)/.generated-code:
PATH=$(DEPSGOBIN):$$PATH mkdir -p ${OUTPUT_DIR}
PATH=$(DEPSGOBIN):$$PATH $(GO_BUILD_FLAGS) go generate ./...
PATH=$(DEPSGOBIN):$$PATH goimports -w $(SUBDIRS)
PATH=$(DEPSGOBIN):$$PATH go mod tidy
PATH=$(DEPSGOBIN):$$PATH touch $@
# run all tests
# set TEST_PKG to run a specific test package
.PHONY: run-tests
run-tests:
ginkgo -r -failFast -trace $(GINKGOFLAGS) \
-ldflags=$(LDFLAGS) \
-gcflags=$(GCFLAGS) \
-progress \
-race \
-compilers=4 \
-skipPackage=$(SKIP_PACKAGES) $(TEST_PKG)
# makes sure you are running codegen with the correct Go version
.PHONY: check-go-version
check-go-version:
./ci/check-go-version.sh