-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (70 loc) · 3 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
TEST?=$$(go list ./... | grep -v 'vendor')
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
BINARY=terraform-provider-thebastion
VERSION=0.1.0
OS_ARCH=darwin_amd64
.PHONY: build release generate install test tools lint depscheck fmt fmtcheck vet testacc
default: install
build: fmtcheck
go build -o ${BINARY}
release:
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64
generate:
go generate ./...
install:
cp .terraformrc ~/.terraformrc
go install .
test:
go test -count=1 -parallel=4 -coverprofile=cover.out ./...
tools:
go install github.com/client9/misspell/cmd/[email protected]
go install github.com/golangci/golangci-lint/cmd/[email protected]
lint:
@echo "==> Checking source code against linters..."
golangci-lint run ./...
depscheck:
@echo "==> Checking source code with 'git diff'..."
@git diff --check || exit 1
@echo "==> Checking source code with go mod tidy..."
@go mod tidy
@git diff --exit-code -- go.mod go.sum || \
(echo; echo "Unexpected difference in go.mod/go.sum files. Run 'go mod tidy' command or revert any go.mod/go.sum changes and commit."; exit 1)
@echo "==> Checking source code with go mod vendor..."
@go mod vendor
@git diff --exit-code -- vendor || \
(echo; echo "Unexpected difference in vendor/ directory. Run 'go mod vendor' command or revert any go.mod/go.sum/vendor changes and commit."; exit 1)
fmt:
@echo "==> Fixing source code with gofmt..."
gofmt -s -w $(GOFMT_FILES)
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi
testacc: fmtcheck
TF_ACC=1 go test -count=1 -parallel=1 -timeout 10m -coverprofile=cover.out -v ./...
cover:
@echo "==> Search coverprofile file..."
@test -f cover.out; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Missing cover.out file. Please run make test or make testacc command first"; \
exit 1; \
fi
@echo "==> Open a web browser displaying annotated source cod"
@go tool cover -html=cover.out