22Q =$(if $V,,@)
33SRC =$(shell find . -type f -name '* .go')
44
5- # protoc-gen-go constraints
6- GEN_GO_BIN ?= protoc-gen-go
7- GEN_GO_MIN_VERSION ?= 1.36.1
8- GEN_GO_VERSION ?= $(shell $(GEN_GO_BIN ) --version | awk -F ' v' '{print $$NF}')
9-
10- # protoc-gen-go-grpc constraints
11- GEN_GRPC_BIN ?= protoc-gen-go-grpc
12- GEN_GRPC_MIN_VERSION ?= 1.5.1
13- GEN_GRPC_VERSION ?= $(shell $(GEN_GRPC_BIN ) --version | awk -F ' ' '{print $$NF}')
14-
155# Go tools
166GOIMPORTS =golang.org/x/tools/cmd/goimports
177GOLANGCI_LINT =github.com/golangci/golangci-lint/v2/cmd/golangci-lint
8+ GOLANGCI_LINT_CONFIG_URL =https://raw.githubusercontent.com/smallstep/workflows/master/.golangci.yml
189GOTESTSUM =gotest.tools/gotestsum
1910GOVULNCHECK =golang.org/x/vuln/cmd/govulncheck
11+ BUF =github.com/bufbuild/buf/cmd/buf
2012
21- all : lint generate test
13+ all : generate lint test
2214
2315ci : test
2416
@@ -30,16 +22,6 @@ ci: test
3022
3123build : ;
3224
33- # ########################################
34- # Bootstrapping
35- # ########################################
36-
37- bootstra% :
38- $Q go install -mod=readonly google.golang.org/protobuf/cmd/protoc-gen-go
39- $Q go install -mod=readonly google.golang.org/grpc/cmd/protoc-gen-go-grpc
40-
41- .PHONY : bootstrap
42-
4325# ########################################
4426# Test
4527# ########################################
6143
6244lint : SHELL:=/bin/bash
6345lint :
64- $Q LOG_LEVEL=error go tool $(GOLANGCI_LINT ) run --config <( curl -s https://raw.githubusercontent.com/smallstep/workflows/master/.golangci.yml ) --timeout=30m
46+ $Q LOG_LEVEL=error go tool $(GOLANGCI_LINT ) run --config <( curl -s $( GOLANGCI_LINT_CONFIG_URL ) ) --timeout=30m ./...
6547 $Q go tool $(GOVULNCHECK ) ./...
6648
6749.PHONY : fmt lint
@@ -70,40 +52,15 @@ lint:
7052# Generate
7153# ########################################
7254
73- generate : check-gen-go-version check-gen-grpc-version
55+ generate :
7456 @# remove any previously generated protobufs & gRPC files
7557 @find . \
7658 -type f \
7759 -name " *.pb.go" \
7860 -delete
7961
8062 @# generate the corresponding protobufs & gRPC code files
81- $Q protoc \
82- --proto_path=spec \
83- --go_opt=module=github.com/smallstep/linkedca \
84- --go_out=. \
85- --go-grpc_opt=module=github.com/smallstep/linkedca \
86- --go-grpc_out=. \
87- $(shell find spec -type f -name "*.proto")
63+ $Q go tool $(BUF) generate -o .
8864
8965.PHONY : generate
9066
91- # ########################################
92- # Tool constraints
93- # ########################################
94-
95- check-gen-go-version :
96- @if ! printf " %s\n%s" " $( GEN_GO_MIN_VERSION) " " $( GEN_GO_VERSION) " | sort -V -C; then \
97- echo " Your $( GEN_GO_BIN) version (v$( GEN_GO_VERSION) ) is older than the minimum required (v$( GEN_GO_MIN_VERSION) )." ; \
98- exit 1; \
99- fi
100-
101- .PHONY : check-gen-go-version
102-
103- check-gen-grpc-version :
104- @if ! printf " %s\n%s" " $( GEN_GRPC_MIN_VERSION) " " $( GEN_GRPC_VERSION) " | sort -V -C; then \
105- echo " Your $( GEN_GRPC_BIN) version (v$( GEN_GRPC_VERSION) ) is older than the minimum required (v$( GEN_GRPC_MIN_VERSION) )." ; \
106- exit 1; \
107- fi
108-
109- .PHONY : check-gen-grpc-version
0 commit comments