1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
# Set V to 1 for verbose output from the Makefile
Q=$(if $V,,@)
SRC=$(shell find . -type f -name '*.go')
all: lint test
ci: test
.PHONY: all ci
#########################################
# Bootstrapping
#########################################
bootstra%:
$Q curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin latest
$Q go install golang.org/x/vuln/cmd/govulncheck@latest
$Q go install gotest.tools/gotestsum@latest
.PHONY: bootstrap
#########################################
# Test
#########################################
test: defaulttest simulatortest combinecoverage
defaulttest:
$Q $(GOFLAGS) gotestsum -- -coverpkg=./... -coverprofile=defaultcoverage.out -covermode=atomic ./...
simulatortest:
$Q $(GOFLAGS) CGO_ENABLED=1 gotestsum -- -coverpkg=./tpm/...,./kms/tpmkms -coverprofile=simulatorcoverage.out -covermode=atomic -tags tpmsimulator ./tpm ./kms/tpmkms
combinecoverage:
cat defaultcoverage.out > coverage.out
tail -n +2 simulatorcoverage.out >> coverage.out
race:
$Q $(GOFLAGS) gotestsum -- -race ./...
.PHONY: test defaulttest simulatortest combinecoverage race
#########################################
# Linting
#########################################
fmt:
$Q goimports -l -w $(SRC)
lint: golint govulncheck
golint: SHELL:=/bin/bash
golint:
$Q LOG_LEVEL=error golangci-lint run --config <(curl -s https://raw.githubusercontent.com/smallstep/workflows/main/.golangci.yml) --timeout=30m
govulncheck:
$Q govulncheck ./...
.PHONY: fmt lint golint govulncheck
#########################################
# Go generate
#########################################
generate:
$Q go generate ./...
.PHONY: generate
|