github.com/Jeffail/benthos/v3@v3.65.0/Makefile (about) 1 .PHONY: all serverless deps docker docker-cgo clean docs test test-race test-integration fmt lint install deploy-docs 2 3 TAGS = 4 5 INSTALL_DIR = $(GOPATH)/bin 6 WEBSITE_DIR = ./website 7 DEST_DIR = ./target 8 PATHINSTBIN = $(DEST_DIR)/bin 9 PATHINSTTOOLS = $(DEST_DIR)/tools 10 PATHINSTSERVERLESS = $(DEST_DIR)/serverless 11 PATHINSTDOCKER = $(DEST_DIR)/docker 12 13 VERSION := $(shell git describe --tags || echo "v0.0.0") 14 VER_CUT := $(shell echo $(VERSION) | cut -c2-) 15 VER_MAJOR := $(shell echo $(VER_CUT) | cut -f1 -d.) 16 VER_MINOR := $(shell echo $(VER_CUT) | cut -f2 -d.) 17 VER_PATCH := $(shell echo $(VER_CUT) | cut -f3 -d.) 18 VER_RC := $(shell echo $(VER_PATCH) | cut -f2 -d-) 19 DATE := $(shell date +"%Y-%m-%dT%H:%M:%SZ") 20 21 VER_FLAGS = -X github.com/Jeffail/benthos/v3/lib/service.Version=$(VERSION) \ 22 -X github.com/Jeffail/benthos/v3/lib/service.DateBuilt=$(DATE) 23 24 LD_FLAGS = -w -s 25 GO_FLAGS = 26 DOCS_FLAGS = 27 28 APPS = benthos 29 all: $(APPS) 30 31 install: $(APPS) 32 @rm -f $(INSTALL_DIR)/benthos 33 @cp $(PATHINSTBIN)/* $(INSTALL_DIR)/ 34 35 deps: 36 @go mod tidy 37 38 SOURCE_FILES = $(shell find lib internal public cmd -type f) 39 TEMPLATE_FILES = $(shell find template -path template/test -prune -o -type f -name "*.yaml") 40 41 $(PATHINSTBIN)/%: $(SOURCE_FILES) $(TEMPLATE_FILES) 42 @go build $(GO_FLAGS) -tags "$(TAGS)" -ldflags "$(LD_FLAGS) $(VER_FLAGS)" -o $@ ./cmd/$* 43 44 $(APPS): %: $(PATHINSTBIN)/% 45 46 TOOLS = benthos_docs_gen 47 tools: $(TOOLS) 48 49 $(PATHINSTTOOLS)/%: $(SOURCE_FILES) $(TEMPLATE_FILES) 50 @go build $(GO_FLAGS) -tags "$(TAGS)" -ldflags "$(LD_FLAGS) $(VER_FLAGS)" -o $@ ./cmd/tools/$* 51 52 $(TOOLS): %: $(PATHINSTTOOLS)/% 53 54 SERVERLESS = benthos-lambda 55 serverless: $(SERVERLESS) 56 57 $(PATHINSTSERVERLESS)/%: $(SOURCE_FILES) $(TEMPLATE_FILES) 58 @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \ 59 go build $(GO_FLAGS) -tags "$(TAGS)" -ldflags "$(LD_FLAGS) $(VER_FLAGS)" -o $@ ./cmd/serverless/$* 60 @zip -m -j $@.zip $@ 61 62 $(SERVERLESS): %: $(PATHINSTSERVERLESS)/% 63 64 docker-tags: 65 @echo "latest,$(VER_CUT),$(VER_MAJOR).$(VER_MINOR),$(VER_MAJOR)" > .tags 66 67 docker-rc-tags: 68 @echo "latest,$(VER_CUT),$(VER_MAJOR)-$(VER_RC)" > .tags 69 70 docker-cgo-tags: 71 @echo "latest-cgo,$(VER_CUT)-cgo,$(VER_MAJOR).$(VER_MINOR)-cgo,$(VER_MAJOR)-cgo" > .tags 72 73 docker: 74 @docker build -f ./resources/docker/Dockerfile . -t jeffail/benthos:$(VER_CUT) 75 @docker tag jeffail/benthos:$(VER_CUT) jeffail/benthos:latest 76 77 docker-cgo: 78 @docker build -f ./resources/docker/Dockerfile.cgo . -t jeffail/benthos:$(VER_CUT)-cgo 79 @docker tag jeffail/benthos:$(VER_CUT)-cgo jeffail/benthos:latest-cgo 80 81 fmt: 82 @go list -f {{.Dir}} ./... | xargs -I{} gofmt -w -s {} 83 @go mod tidy 84 85 lint: 86 @go vet $(GO_FLAGS) ./... 87 @golangci-lint run --timeout 5m cmd/... lib/... internal/... public/... 88 89 test: $(APPS) 90 @go test $(GO_FLAGS) -ldflags "$(LD_FLAGS)" -timeout 3m -race ./... 91 @$(PATHINSTBIN)/benthos test ./config/test/... 92 93 test-integration: 94 $(warning WARNING! Running the integration tests in their entirety consumes a huge amount of computing resources and is likely to time out on most machines. It's recommended that you instead run the integration suite for connectors you are working selectively with `go test -run 'TestIntegration/kafka' ./...` and so on.) 95 @go test $(GO_FLAGS) -ldflags "$(LD_FLAGS)" -run "^Test.*Integration.*$$" -timeout 3m ./... 96 97 clean: 98 rm -rf $(PATHINSTBIN) 99 rm -rf $(DEST_DIR)/dist 100 rm -rf $(DEST_DIR)/tools 101 rm -rf $(DEST_DIR)/serverless 102 rm -rf $(PATHINSTDOCKER) 103 104 docs: $(APPS) $(TOOLS) 105 @$(PATHINSTTOOLS)/benthos_docs_gen $(DOCS_FLAGS) 106 @$(PATHINSTBIN)/benthos lint --deprecated ./config/... \ 107 $(WEBSITE_DIR)/cookbooks/*.md \ 108 $(WEBSITE_DIR)/docs/components/**/about.md \ 109 $(WEBSITE_DIR)/docs/guides/*.md \ 110 $(WEBSITE_DIR)/docs/guides/**/*.md \ 111 $(WEBSITE_DIR)/docs/configuration/*.md