Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 6 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@
Q=$(if $V,,@)
SRC=$(shell find . -type f -name '*.go')

# protoc-gen-go constraints
GEN_GO_BIN ?= protoc-gen-go
GEN_GO_MIN_VERSION ?= 1.36.1
GEN_GO_VERSION ?= $(shell $(GEN_GO_BIN) --version | awk -F ' v' '{print $$NF}')

# protoc-gen-go-grpc constraints
GEN_GRPC_BIN ?= protoc-gen-go-grpc
GEN_GRPC_MIN_VERSION ?= 1.5.1
GEN_GRPC_VERSION ?= $(shell $(GEN_GRPC_BIN) --version | awk -F ' ' '{print $$NF}')

# Go tools
GOIMPORTS=golang.org/x/tools/cmd/goimports
GOLANGCI_LINT=github.com/golangci/golangci-lint/v2/cmd/golangci-lint
GOLANGCI_LINT_CONFIG_URL=https://raw.githubusercontent.com/smallstep/workflows/master/.golangci.yml
GOTESTSUM=gotest.tools/gotestsum
GOVULNCHECK=golang.org/x/vuln/cmd/govulncheck
BUF=github.com/bufbuild/buf/cmd/buf

all: lint generate test
all: generate lint test

ci: test

Expand All @@ -30,16 +22,6 @@ ci: test

build: ;

#########################################
# Bootstrapping
#########################################

bootstra%:
$Q go install -mod=readonly google.golang.org/protobuf/cmd/protoc-gen-go
$Q go install -mod=readonly google.golang.org/grpc/cmd/protoc-gen-go-grpc

.PHONY: bootstrap

#########################################
# Test
#########################################
Expand All @@ -61,7 +43,7 @@ fmt:

lint: SHELL:=/bin/bash
lint:
$Q LOG_LEVEL=error go tool $(GOLANGCI_LINT) run --config <(curl -s https://raw.githubusercontent.com/smallstep/workflows/master/.golangci.yml) --timeout=30m
$Q LOG_LEVEL=error go tool $(GOLANGCI_LINT) run --config <(curl -s $(GOLANGCI_LINT_CONFIG_URL)) --timeout=30m ./...
$Q go tool $(GOVULNCHECK) ./...

.PHONY: fmt lint
Expand All @@ -70,40 +52,15 @@ lint:
# Generate
#########################################

generate: check-gen-go-version check-gen-grpc-version
generate:
@# remove any previously generated protobufs & gRPC files
@find . \
-type f \
-name "*.pb.go" \
-delete

@# generate the corresponding protobufs & gRPC code files
$Q protoc \
--proto_path=spec \
--go_opt=module=github.com/smallstep/linkedca \
--go_out=. \
--go-grpc_opt=module=github.com/smallstep/linkedca \
--go-grpc_out=. \
$(shell find spec -type f -name "*.proto")
$Q go tool $(BUF) generate -o .

.PHONY: generate

#########################################
# Tool constraints
#########################################

check-gen-go-version:
@if ! printf "%s\n%s" "$(GEN_GO_MIN_VERSION)" "$(GEN_GO_VERSION)" | sort -V -C; then \
echo "Your $(GEN_GO_BIN) version (v$(GEN_GO_VERSION)) is older than the minimum required (v$(GEN_GO_MIN_VERSION))."; \
exit 1; \
fi

.PHONY: check-gen-go-version

check-gen-grpc-version:
@if ! printf "%s\n%s" "$(GEN_GRPC_MIN_VERSION)" "$(GEN_GRPC_VERSION)" | sort -V -C; then \
echo "Your $(GEN_GRPC_BIN) version (v$(GEN_GRPC_VERSION)) is older than the minimum required (v$(GEN_GRPC_MIN_VERSION))."; \
exit 1; \
fi

.PHONY: check-gen-grpc-version
8 changes: 5 additions & 3 deletions admin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: v2

managed:
enabled: true

inputs:
- directory: proto

plugins:
- local: [go, tool, google.golang.org/protobuf/cmd/protoc-gen-go]
out: .
opt:
- module=github.com/smallstep/linkedca

- local: [go, tool, google.golang.org/grpc/cmd/protoc-gen-go-grpc]
out: .
opt:
- module=github.com/smallstep/linkedca
- require_unimplemented_servers=true
12 changes: 12 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: v2

lint:
use:
- STANDARD

breaking:
use:
- FILE

modules:
- path: proto
7 changes: 4 additions & 3 deletions config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions eab.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading