-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
133 lines (102 loc) · 3.22 KB
/
Makefile
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
BINARY=enos
VERSION=$$($(CURRENT_DIRECTORY)/.release/build-scripts/version.sh version/version.go)
GIT_SHA=$$(git rev-parse HEAD)
CURRENT_DIRECTORY := $(shell pwd)
BUILD_BINARY_PATH=${CURRENT_DIRECTORY}/dist/${BINARY}
REPO=github.com/hashicorp/enos
GO_BUILD_TAGS=-tags osusergo,netgo
GO_LD_FLAGS=-ldflags="-extldflags=-static -X ${REPO}/internal/version.Version=${VERSION} -X ${REPO}/internal/version.GitSHA=${GIT_SHA}"
GO_GC_FLAGS?=
LINT_OUT_FORMAT?=colored-line-number
BUF_LINT_OUT_FORMAT?=github-actions
GORACE=GORACE=log_path=/tmp/enos-gorace.log
TEST_ACC=ENOS_ACC=1
TEST_ACC_EXT=ENOS_ACC=1 ENOS_EXT=1
.PHONY: default
default: build
.PHONY: all
all: generate build profile build-profile
.PHONY: generate
generate: generate-proto
.PHONY: generate-proto
generate-proto:
buf generate
.PHONY: build
build:
CGO_ENABLED=0 go build ${GO_BUILD_TAGS} ${GO_LD_FLAGS} ${GO_GC_FLAGS} -o dist/${BINARY} ./command/enos
.PHONY: build-profile
build-profile:
CGO_ENABLED=0 go build ${GO_BUILD_TAGS} ${GO_LD_FLAGS} ${GO_GC_FLAGS} -pgo=default.pgo -o dist/${BINARY} ./command/enos
.PHONY: build-race
build-race:
${GORACE} go build -race ${GO_BUILD_TAGS} ${GO_LD_FLAGS} ${GO_GC_FLAGS} -o dist/${BINARY} ./command/enos
.PHONY: test
test:
${GORACE} go test -race ./... $(TESTARGS) -timeout=5m -parallel=4
.PHONY: test-acc
test-acc: build-race
${TEST_ACC} ${GORACE} ENOS_BINARY_PATH=${BUILD_BINARY_PATH} go test -race ./... $(TESTARGS) -timeout 120m
.PHONY: test-acc-ext
test-acc-ext: build-race
${TEST_ACC_EXT} ${GORACE} ENOS_BINARY_PATH=${BUILD_BINARY_PATH} go test -race ./... $(TESTARGS) -timeout 120m
.PHONY: lint
lint: lint-golang lint-proto
.PHONY: lint-golang
lint-golang:
golangci-lint run -v
.PHONY: lint-fix
lint-fix: lint-fix-golang
.PHONY: lint-fix-golang
lint-fix-golang:
golangci-lint run -v --out-format=$(LINT_OUT_FORMAT) --fix
.PHONY: lint-proto
lint-proto:
buf lint --error-format=$(BUF_LINT_OUT_FORMAT)
.PHONY: fmt
fmt: fmt-golang fmt-proto fmt-terraform fmt-enos
.PHONY: fmt-check
fmt-check: fmt-check-golang fmt-check-proto fmt-check-terraform fmt-check-enos
.PHONY: fmt-golang
fmt-golang:
gofumpt -w -l .
.PHONY: fmt-check-golang
fmt-check-golang:
gofumpt -d -l .
.PHONY: fmt-proto
fmt-proto:
buf format proto -w
.PHONY: fmt-check-proto
fmt-check-proto:
buf format proto -d --exit-code
.PHONY: fmt-terraform
fmt-terraform:
terraform fmt -recursive acceptance/scenarios
.PHONY: fmt-check-terraform
fmt-check-terraform:
terraform fmt -check -diff -recursive acceptance/scenarios
.PHONY: fmt-enos
fmt-enos:
dist/enos fmt --recursive acceptance/scenarios
.PHONY: fmt-check-enos
fmt-check-enos:
dist/enos fmt --check --diff --recursive acceptance/scenarios
.PHONY: clean
clean:
rm -rf dist enos
.PHONY: deps
deps: deps-build deps-lint
.PHONY: deps-build
deps-build:
go install github.com/golang/protobuf/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/bufbuild/buf/cmd/buf@latest
.PHONY: deps-lint
deps-lint:
go install mvdan.cc/gofumpt@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
.PHONY: profile
profile:
@$(CURRENT_DIRECTORY)/tools/profile/profile.sh
.PHONY: version
version:
@$(CURRENT_DIRECTORY)/.release/build-scripts/version.sh version/version.go