forked from vmware/terraform-provider-vcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGNUmakefile
149 lines (115 loc) · 4.32 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
TEST?=$$(go list ./... |grep -v 'vendor')
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
WEBSITE_REPO=github.com/hashicorp/terraform-website
PKG_NAME=vcd
default: build
# builds the plugin
build: fmtcheck
go install
# creates a .zip archive of the code
dist:
git archive --format=zip -o source.zip HEAD
git archive --format=tar HEAD | gzip -c > source.tar.gz
# builds and deploys the plugin
install: build
@sh -c "'$(CURDIR)/scripts/install-plugin.sh'"
# makes .tf files from test templates
test-binary-prepare: install
@sh -c "'$(CURDIR)/scripts/runtest.sh' short-provider"
@sh -c "'$(CURDIR)/scripts/runtest.sh' binary-prepare"
# runs test using Terraform binary
test-binary: install
@sh -c "'$(CURDIR)/scripts/runtest.sh' short-provider"
@sh -c "'$(CURDIR)/scripts/runtest.sh' binary"
# prepares to build the environment in a new vCD (run once before test-env-apply)
test-env-init: install
@sh -c "'$(CURDIR)/scripts/runtest.sh' short-provider"
@sh -c "'$(CURDIR)/scripts/runtest.sh' test-env-init"
# build the environment in a new vCD (run once before testacc)
test-env-apply:
@sh -c "'$(CURDIR)/scripts/runtest.sh' test-env-apply"
# destroys the environment built with 'test-env-apply' (warning: can't be undone)
test-env-destroy:
@sh -c "'$(CURDIR)/scripts/runtest.sh' test-env-destroy"
# runs the unit tests
testunit: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' unit"
# Runs the basic execution test
test: testunit
@sh -c "'$(CURDIR)/scripts/runtest.sh' short"
# Runs the full acceptance test
testacc: testunit
@sh -c "'$(CURDIR)/scripts/runtest.sh' acceptance"
# Runs full acceptance test sequentially (using "-parallel 1" flag for go test)
seqtestacc: testunit
@sh -c "'$(CURDIR)/scripts/runtest.sh' sequential-acceptance"
# Runs the acceptance test with tag 'multiple'
testmulti: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' multiple"
# Runs the acceptance test for org
testorg: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' org"
# Runs the acceptance test for catalog
testcatalog: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' catalog"
# Runs the acceptance test for vapp
testvapp: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' vapp"
# Runs the acceptance test for lb
testlb: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' lb"
# Runs the acceptance test for user
testuser: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' user"
# Runs the acceptance test for vm
testvm: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' vm"
# Runs the acceptance test for gateway
testgateway: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' gateway"
# Runs the acceptance test for network
testnetwork: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' network"
# Runs the acceptance test for external network
testextnetwork: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' extnetwork"
# vets all .go files
vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -ne 0 ]; 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
# formats all .go files
fmt:
gofmt -w $(GOFMT_FILES)
# runs a Go format check
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
# runs the vendor directory check
vendor-check:
go mod tidy
go mod vendor
git diff --exit-code
# checks that the code can compile
test-compile:
cd vcd && go test -tags ALL -c .
# builds the website and allows running it from localhost
website:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
# tests the website files for broken link
website-test:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
.PHONY: build test seqtestacc testacc vet fmt fmtcheck errcheck vendor-check test-compile website website-test