Evgenii Stratonikov
a85146250b
All checks were successful
DCO action / DCO (pull_request) Successful in 1m17s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m22s
Tests and linters / Lint (pull_request) Successful in 2m51s
Tests and linters / Tests (1.19) (pull_request) Successful in 2m48s
Tests and linters / Tests with -race (pull_request) Successful in 2m40s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
73 lines
1.8 KiB
Makefile
Executable file
73 lines
1.8 KiB
Makefile
Executable file
#!/usr/bin/make -f
|
|
SHELL = bash
|
|
|
|
VERSION ?= $(shell git describe --tags --match "v*" --abbrev=8 --dirty --always)
|
|
|
|
.PHONY: dep fmts fumpt imports protoc test lint version help
|
|
|
|
# Pull go dependencies
|
|
dep:
|
|
@printf "⇒ Tidy requirements : "
|
|
CGO_ENABLED=0 \
|
|
go mod tidy -v && echo OK
|
|
@printf "⇒ Download requirements: "
|
|
CGO_ENABLED=0 \
|
|
go mod download && echo OK
|
|
@printf "⇒ Install test requirements: "
|
|
CGO_ENABLED=0 \
|
|
go test ./... && echo OK
|
|
|
|
# Run all code formatters
|
|
fmts: fumpt imports
|
|
|
|
# Reformat imports
|
|
imports:
|
|
@echo "⇒ Processing goimports check"
|
|
@for f in `find . -type f -name '*.go' -not -path './vendor/*' -not -name '*.pb.go' -prune`; do \
|
|
goimports -w $$f; \
|
|
done
|
|
|
|
# Run gofumpt
|
|
fumpt:
|
|
@echo "⇒ Processing gofumpt check"
|
|
@gofumpt -l -w .
|
|
|
|
# Regenerate code for proto files
|
|
protoc:
|
|
@GOPRIVATE=github.com/TrueCloudLab go mod vendor
|
|
# Install specific version for protobuf lib
|
|
@go list -f '{{.Path}}/...@{{.Version}}' -m google.golang.org/protobuf | xargs go install -v
|
|
# Protoc generate
|
|
@for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \
|
|
echo "⇒ Processing $$f "; \
|
|
protoc \
|
|
--proto_path=.:./vendor:/usr/local/include \
|
|
--go_out=. --go_opt=paths=source_relative \
|
|
--go-grpc_opt=require_unimplemented_servers=false \
|
|
--go-grpc_out=. --go-grpc_opt=paths=source_relative $$f; \
|
|
done
|
|
rm -rf vendor
|
|
|
|
# Run Unit Test with go test
|
|
test: GOFLAGS ?= "-count=1"
|
|
test:
|
|
@echo "⇒ Running go test"
|
|
@GOFLAGS="$(GOFLAGS)" go test ./...
|
|
|
|
# Run linters
|
|
lint:
|
|
@golangci-lint run
|
|
|
|
# Print version
|
|
version:
|
|
@echo $(VERSION)
|
|
|
|
# Show this help prompt
|
|
help:
|
|
@echo ' Usage:'
|
|
@echo ''
|
|
@echo ' make <target>'
|
|
@echo ''
|
|
@echo ' Targets:'
|
|
@echo ''
|
|
@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
|