-
Notifications
You must be signed in to change notification settings - Fork 380
/
GNUmakefile
90 lines (70 loc) · 2.85 KB
/
GNUmakefile
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
TEST?=$$(go list ./...)
RECORD?=false
GOIMPORTS_FILES?=$$(find . -name '*.go')
PKG_NAME=datadog
DIR=~/.terraform.d/plugins
ZORKIAN_VERSION?=master
API_CLIENT_VERSION?=master
LOCAL_PACKAGE="github.com/terraform-providers/terraform-provider-datadog"
default: build
build: fmtcheck
go install
install: fmtcheck
mkdir -vp $(DIR)
go build -o $(DIR)/terraform-provider-datadog
uninstall:
@rm -vf $(DIR)/terraform-provider-datadog
# Run unit tests; these tests don't interact with the API and don't support/need RECORD
test: get-test-deps fmtcheck
gotestsum --hide-summary skipped --format testname --debug --packages $(TEST) -- $(TESTARGS) -timeout=30s
# Run acceptance tests (this runs integration CRUD tests through the terraform test framework)
testacc: get-test-deps
RECORD=$(RECORD) TF_ACC=1 gotestsum --format testname --debug --rerun-fails --packages ./... -- -v $(TESTARGS) -timeout 120m
# Run both unit and acceptance tests
testall: test testacc
cassettes: get-test-deps fmtcheck
RECORD=true TF_ACC=1 gotestsum --format testname --packages ./... -- -v $(TESTARGS) -timeout 120m
vet:
@echo "go vet ."
@go vet $$(go list ./...) ; 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:
goimports -format-only -local $(LOCAL_PACKAGE) -w $(GOIMPORTS_FILES)
terraform fmt -recursive examples
fmtcheck:
@sh -c "'$(CURDIR)/scripts/fmtcheck.sh'"
errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
test-compile: get-test-deps
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
echo " make test-compile TEST=./$(PKG_NAME)"; \
exit 1; \
fi
gotestsum --format testname -- -c $(TEST) $(TESTARGS)
update-go-client:
echo "Updating the Zorkian client to ${ZORKIAN_VERSION} and the API Client to ${API_CLIENT_VERSION}"
go get github.com/zorkian/go-datadog-api@$(ZORKIAN_VERSION)
go get github.com/DataDog/datadog-api-client-go/v2@${API_CLIENT_VERSION}
go mod tidy
get-test-deps:
gotestsum --version || go install gotest.tools/gotestsum@latest
which goimports || go install golang.org/x/tools/cmd/goimports@latest
license-check:
@sh -c "'$(CURDIR)/scripts/license-check.sh'"
tools:
go generate -tags tools tools/tools.go
docs: tools
@sh -c "'$(CURDIR)/scripts/generate-docs.sh'"
check-docs: docs
@if [ "`git status --porcelain docs/`" ]; then \
git diff; \
echo "Uncommitted changes were detected in the autogenerated docs folder. Please run 'make docs' to autogenerate the docs, and commit the changes" && echo `git status --porcelain docs/` && exit 1; \
else \
echo "Success: No generated documentation changes detected"; \
fi
.PHONY: build check-docs docs test testall testacc cassettes vet fmt fmtcheck errcheck test-compile tools get-test-deps license-check