forked from anexia-it/terraform-provider-anxcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (96 loc) · 4.36 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
export GOPATH?=$(shell go env GOPATH)
export GOPROXY=https://proxy.golang.org
export GO111MODULE=on
HOSTNAME=hashicorp.com
NAMESPACE=anexia-it
NAME=anxcloud
BINARY=terraform-provider-${NAME}
VERSION=0.3.1
OS_ARCH=linux_amd64
GOLDFLAGS= -s -X github.com/anexia-it/terraform-provider-anxcloud/anxcloud.providerVersion=$(VERSION)
TEST?=$$(go list ./... | grep -v 'vendor')
GOFMT_FILES := $(find ./anxcloud -name '*.go' |grep -v vendor)
default: install
.PHONY: build
build: fmtcheck go-lint
go build -o ${BINARY}
.PHONY: release
release: fmtcheck lint test testacc
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 -ldflags "$(GOLDFLAGS)"
GOOS=darwin GOARCH=arm64 go build -o ./bin/${BINARY}_${VERSION}_darwin_arm64 -ldflags "$(GOLDFLAGS)"
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 -ldflags "$(GOLDFLAGS)"
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 -ldflags "$(GOLDFLAGS)"
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm -ldflags "$(GOLDFLAGS)"
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386 -ldflags "$(GOLDFLAGS)"
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64 -ldflags "$(GOLDFLAGS)"
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm -ldflags "$(GOLDFLAGS)"
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386 -ldflags "$(GOLDFLAGS)"
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 -ldflags "$(GOLDFLAGS)"
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64 -ldflags "$(GOLDFLAGS)"
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386 -ldflags "$(GOLDFLAGS)"
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64 -ldflags "$(GOLDFLAGS)"
.PHONY: install
install: build
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
.PHONY: test
test: fmtcheck
go test -i $(TEST) || exit 1
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
.PHONY: testacc
testacc: fmtcheck
@if [ "$(TESTARGS)" = "-run=TestAccXXX" ]; then \
echo ""; \
echo "Error: Skipping example acceptance testing pattern. Update TESTARGS to match the test naming in the relevant *_test.go file."; \
echo "Example:"; \
echo ""; \
echo " make testacc TESTARGS='-run=TestAccAnxCloudVirtualServer'"; \
echo ""; \
exit 1; \
fi
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -parallel=4
.PHONY: fmt
fmt:
gofmt -w $(GOFMT_FILES)
.PHONY: fmtcheck
fmtcheck:
@./scripts/gofmtcheck.sh
.PHONY: depscheck
depscheck:
@echo "==> Checking source code dependencies..."
@go mod tidy
@git diff --exit-code -- go.mod go.sum || \
(echo; echo "Found differences in go.mod/go.sum files. Run 'go mod tidy' or revert go.mod/go.sum changes."; exit 1)
.PHONY: tools
tools:
cd tools && go install github.com/client9/misspell/cmd/misspell
cd tools && go install github.com/golangci/golangci-lint/cmd/golangci-lint
cd tools && go install github.com/katbyte/terrafmt
.PHONY: docs-lint
docs-lint:
@echo "==> Checking docs against linters..."
@misspell -error -source=text docs/ || (echo; \
echo "Unexpected misspelling found in docs files."; \
echo "To automatically fix the misspelling, run 'make docs-lint-fix' and commit the changes."; \
exit 1)
@docker run -v $(PWD):/markdown 06kellyjac/markdownlint-cli docs/ || (echo; \
echo "Unexpected issues found in docs Markdown files."; \
echo "To apply any automatic fixes, run 'make docs-lint-fix' and commit the changes."; \
exit 1)
@terrafmt diff ./docs --check --pattern '*.md' --quiet || (echo; \
echo "Unexpected differences in docs HCL formatting."; \
echo "To see the full differences, run: terrafmt diff ./docs --pattern '*.md'"; \
echo "To automatically fix the formatting, run 'make docs-lint-fix' and commit the changes."; \
exit 1)
.PHONY: docs-lint-fix
docs-lint-fix:
@echo "==> Applying automatic docs linter fixes..."
@misspell -w -source=text docs/
@docker run -v $(PWD):/markdown 06kellyjac/markdownlint-cli --fix docs/
@terrafmt fmt ./docs --pattern '*.md'
.PHONY: go-lint
go-lint:
@echo "==> Checking source code against linters..."
@golangci-lint run ./$(NAME)
.PHONY: lint
lint: go-lint docs-lint