| 1 |
# Set V to 1 for verbose output from the Makefile |
| 2 |
Q=$(if $V,,@) |
| 3 |
SRC=$(shell find . -type f -name '*.go') |
| 4 |
|
| 5 |
all: lint generate test |
| 6 |
|
| 7 |
ci: test |
| 8 |
|
| 9 |
.PHONY: all ci |
| 10 |
|
| 11 |
######################################### |
| 12 |
# Build |
| 13 |
######################################### |
| 14 |
|
| 15 |
build: ; |
| 16 |
|
| 17 |
######################################### |
| 18 |
# Bootstrapping |
| 19 |
######################################### |
| 20 |
|
| 21 |
bootstra%: |
| 22 |
$Q curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.49.0 |
| 23 |
$Q go install golang.org/x/vuln/cmd/govulncheck@latest |
| 24 |
$Q go install gotest.tools/[email protected] |
| 25 |
|
| 26 |
.PHONY: bootstrap |
| 27 |
|
| 28 |
######################################### |
| 29 |
# Test |
| 30 |
######################################### |
| 31 |
|
| 32 |
test: |
| 33 |
$Q $(GOFLAGS) gotestsum -- -coverpkg=./... -coverprofile=coverage.out -covermode=atomic ./... |
| 34 |
|
| 35 |
race: |
| 36 |
$Q $(GOFLAGS) gotestsum -- -race ./... |
| 37 |
|
| 38 |
.PHONY: test race |
| 39 |
|
| 40 |
######################################### |
| 41 |
# Linting |
| 42 |
######################################### |
| 43 |
|
| 44 |
fmt: |
| 45 |
$Q goimports -local github.com/golangci/golangci-lint -l -w $(SRC) |
| 46 |
|
| 47 |
lint: SHELL:=/bin/bash |
| 48 |
lint: |
| 49 |
$Q LOG_LEVEL=error golangci-lint run --config <(curl -s https://raw.githubusercontent.com/smallstep/workflows/master/.golangci.yml) --timeout=30m |
| 50 |
$Q govulncheck ./... |
| 51 |
|
| 52 |
.PHONY: fmt lint |
| 53 |
|
| 54 |
######################################### |
| 55 |
# Generate |
| 56 |
######################################### |
| 57 |
|
| 58 |
generate: |
| 59 |
protoc --proto_path=. --go_out=. --go-grpc_out=. --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative provisioners.proto admin.proto config.proto eab.proto majordomo.proto policy.proto |
| 60 |
|
| 61 |
.PHONY: generate |