github.com/TrueCloudLab/frostfs-api-go/v2@v2.0.0-20230228134343-196241c4e79a/Makefile (about) 1 #!/usr/bin/make -f 2 SHELL = bash 3 4 VERSION ?= $(shell git describe --tags --match "v*" --abbrev=8 --dirty --always) 5 6 .PHONY: dep fmts fmt imports protoc test lint version help 7 8 # Pull go dependencies 9 dep: 10 @printf "⇒ Tidy requirements : " 11 CGO_ENABLED=0 \ 12 GO111MODULE=on \ 13 go mod tidy -v && echo OK 14 @printf "⇒ Download requirements: " 15 CGO_ENABLED=0 \ 16 GO111MODULE=on \ 17 go mod download && echo OK 18 @printf "⇒ Install test requirements: " 19 CGO_ENABLED=0 \ 20 GO111MODULE=on \ 21 go test ./... && echo OK 22 23 # Run all code formatters 24 fmts: fmt imports 25 26 # Reformat code 27 fmt: 28 @echo "⇒ Processing gofmt check" 29 @for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \ 30 GO111MODULE=on gofmt -s -w $$f; \ 31 done 32 33 # Reformat imports 34 imports: 35 @echo "⇒ Processing goimports check" 36 @for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \ 37 GO111MODULE=on goimports -w $$f; \ 38 done 39 40 # Regenerate code for proto files 41 protoc: 42 @GOPRIVATE=github.com/TrueCloudLab go mod vendor 43 # Install specific version for protobuf lib 44 @go list -f '{{.Path}}/...@{{.Version}}' -m google.golang.org/protobuf | xargs go install -v 45 # Protoc generate 46 @for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \ 47 echo "⇒ Processing $$f "; \ 48 protoc \ 49 --proto_path=.:./vendor:/usr/local/include \ 50 --go_out=. --go_opt=paths=source_relative \ 51 --go-grpc_opt=require_unimplemented_servers=false \ 52 --go-grpc_out=. --go-grpc_opt=paths=source_relative $$f; \ 53 done 54 rm -rf vendor 55 56 # Run Unit Test with go test 57 test: 58 @echo "⇒ Running go test" 59 @GO111MODULE=on go test ./... 60 61 # Run linters 62 lint: 63 @golangci-lint run 64 65 # Print version 66 version: 67 @echo $(VERSION) 68 69 # Show this help prompt 70 help: 71 @echo ' Usage:' 72 @echo '' 73 @echo ' make <target>' 74 @echo '' 75 @echo ' Targets:' 76 @echo '' 77 @awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort -u