1- # If you update this file, please follow
2- # https://suva.sh/posts/well-documented-makefiles
3-
41.DEFAULT_GOAL: =help
52
6- ifeq ($(GOPROXY ) ,)
7- export GOPROXY = direct
8- endif
9-
10- # Directories.
11- TOOLS_DIR := hack/tools
3+ BIN_DIR ?= bin
4+ TOOLS_DIR := hack/tools
125TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
13- BIN_DIR := bin
14-
15- # Binaries.
166GOLANGCI_LINT := $(TOOLS_BIN_DIR ) /golangci-lint
177
18- # Golang build env
19- LDFLAGS := -s -w
20-
218GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD | sed 's/\///g')
229GIT_COMMIT = $(shell git rev-parse HEAD)
2310GIT_SHA = $(shell git rev-parse --short HEAD)
@@ -28,29 +15,36 @@ ifneq ($(GIT_TAG),)
2815 VERSION = $(GIT_TAG)
2916endif
3017
31- LDFLAGS += -X "github.com/criticalstack/e2d/pkg/buildinfo.Date=$(shell date -u +'% Y-% m-% dT% TZ') "
32- LDFLAGS += -X "github.com/criticalstack/e2d/pkg/buildinfo.GitSHA=$(GIT_SHA ) "
33- LDFLAGS += -X "github.com/criticalstack/e2d/pkg/buildinfo.Version=$(VERSION ) "
18+ LDFLAGS := -s -w
19+ LDFLAGS += -X "github.com/criticalstack/e2d/internal/buildinfo.Date=$(shell date -u +'% Y-% m-% dT% TZ') "
20+ LDFLAGS += -X "github.com/criticalstack/e2d/internal/buildinfo.GitSHA=$(GIT_SHA ) "
21+ LDFLAGS += -X "github.com/criticalstack/e2d/internal/buildinfo.Version=$(VERSION ) "
3422GOFLAGS = -gcflags "all=-trimpath=$(PWD ) " -asmflags "all=-trimpath=$(PWD ) "
3523
3624GO_BUILD_ENV_VARS := GO111MODULE=on CGO_ENABLED=0
3725
38- .PHONY : build test test-manager clean
26+ # #@ Building
3927
40- build : clean # # Build the e2d golang binary
28+ .PHONY : e2d
29+
30+ e2d : # # Build the e2d golang binary
4131 $(GO_BUILD_ENV_VARS ) go build -o bin/e2d $(GOFLAGS ) -ldflags ' $(LDFLAGS)' ./cmd/e2d
4232
43- test : # # Run all tests
44- go test ./...
33+ .PHONY : update-codegen
34+ update-codegen : # # Update generated code (slow)
35+ @echo " Updating generated code files ..."
36+ @echo " *** This can be slow and does not need to run every build ***"
37+ @hack/tools/update-codegen.sh
4538
46- test-manager : # # Test the manager package
47- go test ./pkg/manager -test.long
39+ # #@ Testing
4840
49- clean : # # Cleanup the project folders
50- @rm -rf ./bin/*
51- @rm -rf hack/tools/bin
41+ .PHONY : test test-e2e lint lint-full
42+
43+ test : # # Run all tests
44+ @go test $(shell go list ./... | grep -v e2e)
5245
53- .PHONY : lint
46+ test-e2e : # # Run e2e tests
47+ @go test ./e2e -parallel=16 -count=1
5448
5549lint : $(GOLANGCI_LINT ) # # Lint codebase
5650 $(GOLANGCI_LINT ) run -v
@@ -60,15 +54,20 @@ lint-full: $(GOLANGCI_LINT) ## Run slower linters to detect possible issues
6054
6155# #@ Helpers
6256
63- .PHONY : help
57+ .PHONY : help clean
6458
6559$(GOLANGCI_LINT ) : $(TOOLS_DIR ) /go.mod # Build golangci-lint from tools folder.
6660 cd $(TOOLS_DIR ) ; go build -tags=tools -o $(BIN_DIR ) /golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
6761
62+ clean : # # Cleanup the project folders
63+ @rm -rf ./bin/*
64+ @rm -rf hack/tools/bin
65+
6866help : # # Display this help
69- @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_ -]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
67+ @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_ -]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
7068
7169
70+ # TODO: move to hack/tools
7271generate :
7372 protoc -I pkg/manager/e2dpb \
7473 -I vendor/ \
0 commit comments