-
Notifications
You must be signed in to change notification settings - Fork 111
/
GNUmakefile
195 lines (150 loc) · 5.97 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
TEST?=$$(go list ./... )
GOFMT_FILES?=$$(find . -name '*.go' )
WEBSITE_REPO=github.com/hashicorp/terraform-website
GIT_DESCRIBE=$(shell git describe --tags)
PKG_NAME=vcd
default: build
# builds the plugin injecting output of `git describe` to BuildVersion variable
build: fmtcheck
go install -ldflags="-X 'github.com/vmware/terraform-provider-vcd/v4/vcd.BuildVersion=$(GIT_DESCRIBE)'"
# builds the plugin with race detector enabled and injecting output of `git describe` to BuildVersion variable
buildrace: fmtcheck
go install --race -ldflags="-X 'github.com/vmware/terraform-provider-vcd/v4/vcd.BuildVersion=$(GIT_DESCRIBE)'"
# 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
# triggers cleanup by executing a non existent test
cleanup:
cd vcd && go test -tags ALL -run "NoSuchTest\b" -v -timeout 0
# builds and deploys the plugin
install: build
@sh -c "'$(CURDIR)/scripts/install-plugin.sh'"
# builds and deploys the plugin with race detector enabled (useful for troubleshooting)
installrace: buildrace
@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"
# validates HCL files without executing them
test-binary-validate: install
@sh -c "'$(CURDIR)/scripts/runtest.sh' short-provider"
@sh -c "'$(CURDIR)/scripts/runtest.sh' binary-validate"
# runs test using Terraform binary as Org user
test-binary-orguser: install
@sh -c "'$(CURDIR)/scripts/runtest.sh' short-provider-orguser"
@sh -c "'$(CURDIR)/scripts/runtest.sh' binary"
# runs upgrade test using Terraform binary
test-upgrade:
@sh -c "'$(CURDIR)/scripts/test-upgrade.sh'"
# makes .tf files from test templates for upgrade testing, but does not execute them
test-upgrade-prepare:
@sh -c "skip_upgrade_execution=1 '$(CURDIR)/scripts/test-upgrade.sh'"
# runs test using Terraform binary as system administrator using binary with race detection enabled
test-binary: installrace
@sh -c "'$(CURDIR)/scripts/runtest.sh' short-provider"
@sh -c "'$(CURDIR)/scripts/runtest.sh' binary"
# Retrieves the authorization token
token:
@sh -c "'$(CURDIR)/scripts/runtest.sh' token"
# runs staticcheck
static: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' static"
# security runs the source code security analysis tool `gosec`
security: fmtcheck
@./scripts/gosec.sh
# runs the unit tests
testunit: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' unit"
# Runs the basic execution test
test: testunit tagverify
@sh -c "'$(CURDIR)/scripts/runtest.sh' short"
# Runs the full acceptance test as Org user
testacc-orguser: testunit
@sh -c "'$(CURDIR)/scripts/runtest.sh' acceptance-orguser"
# Runs the full acceptance test as system administrator
testacc: testunit
@sh -c "'$(CURDIR)/scripts/runtest.sh' acceptance"
# Runs the acceptance test as system administrator for search label
test-search: testunit
@sh -c "'$(CURDIR)/scripts/runtest.sh' search"
# Runs full acceptance test sequentially (using "-parallel 1" flag for go test)
testacc-race-seq: 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"
# Runs the acceptance test for tm
testtm: fmtcheck
@sh -c "'$(CURDIR)/scripts/runtest.sh' tm"
# vets all .go files
vet:
@echo "go vet ."
@go vet -tags ALL $$(go list ./... ) ; 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 -s -w $(GOFMT_FILES)
# runs a Go format check
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
# runs HCL validation
hclcheck:
@sh -c "'$(CURDIR)/scripts/hcl-check.sh'"
# runs the go tidy directory check
tidy-check:
go mod tidy
git diff --exit-code
# checks that the code can compile
test-compile:
cd vcd && go test -race -tags ALL -c .
# checks that tagged tests can run independently
tagverify:
@scripts/test-tags.sh
# 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 testacc-race-seq testacc vet static fmt fmtcheck tidy-check test-compile website website-test