-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathGNUmakefile
More file actions
92 lines (73 loc) · 3.11 KB
/
Copy pathGNUmakefile
File metadata and controls
92 lines (73 loc) · 3.11 KB
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
TEST?=$$(go list ./...)
GOFMT_FILES?=$$(find . -name '*.go')
WEBSITE_REPO=github.com/hashicorp/terraform-website
PKG_NAME=nsxt
GIT_COMMIT=$$(git rev-list -1 HEAD)
BUILD_PATH=$$(go env GOPATH)
default: build
tools:
GO111MODULE=on go install -mod=mod github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45
GO111MODULE=on go install -mod=mod github.com/katbyte/terrafmt
build: fmtcheck
go install -ldflags "-X github.com/vmware/terraform-provider-nsxt/nsxt.GitCommit=$(GIT_COMMIT)"
build-coverage:
go build -cover -ldflags "-X github.com/vmware/terraform-provider-nsxt/nsxt.GitCommit=$(GIT_COMMIT)" -o $(BUILD_PATH)/bin
build-debug:
go build -gcflags="all=-N -l" -ldflags "-X github.com/vmware/terraform-provider-nsxt/nsxt.GitCommit=$(GIT_COMMIT)" -o $(BUILD_PATH)/bin
test: fmtcheck
go test -i $(TEST) || exit 1
echo $(TEST) | \
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
testacc: fmtcheck
GO111MODULE=on TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 360m
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
fmt:
gofmt -w $(GOFMT_FILES)
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
test-unit:
go test -v ./nsxt -tags=unittest -run='^(TestMock.*Nsxt.*|TestUnitNsxt_.*)'
test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
echo " make test-compile TEST=./$(PKG_NAME)"; \
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)
test-hcl:
@echo "==> Checking HCL formatting in tests..."
@terrafmt diff ./nsxt --check --pattern '*_test.go' --quiet || (echo; \
echo "Unexpected differences in HCL formatting for tests."; \
echo "To see the full differences, run: terrafmt diff ./nsxt --pattern '*_test.go'"; \
echo "To automatically fix the formatting, run 'make test-hcl-fix' and commit the changes."; \
exit 1)
docs-lint:
@echo "==> Applying HCL formatting for docs..."
@terrafmt diff ./docs --check --pattern '*.md' --quiet || (echo; \
echo "Unexpected differences in HCL formatting for docs."; \
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)
docs-lint-fix:
@echo "==> Applying HCL formatting to docs..."
@terrafmt fmt ./docs --pattern '*.md'
docs-list-category:
@find . -name *.md | xargs grep subcategory | awk -F '"' '{print $$2}' | sort | uniq
.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile docs-lint docs-lint-fix tools
api-wrapper:
@echo "==> Generating API wrappers..."
/usr/bin/python3 $(CURDIR)/tools/api-wrapper-generator.py \
--api_list $(CURDIR)/api/api_list.yaml \
--api_template $(CURDIR)/api/api_templates.yaml \
--api_file_template $(CURDIR)/api/api_file_template.yaml \
--utl_file_template $(CURDIR)/api/utl_file_template.yaml \
--out_dir $(CURDIR)/api