forked from oracle/terraform-provider-oci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
123 lines (102 loc) · 4.33 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
TEST?=./...
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
PKG_NAME=oci
WEBSITE_REPO=github.com/hashicorp/terraform-website
prefix := $(if $(debug),TF_LOG=DEBUG OCI_GO_SDK_DEBUG=1, )
timeout := $(if $(timeout), $(timeout), 120m)
run_regex := $(if $(run), -run $(run), )
skip_goimports_check_flag := $(if $(skip_goimports_check), -s, )
default: build
## IMPORTANT: Do not modify the following `build` target. The following steps are a requirement of the provider release process.
build: fmtcheck
go install
### TODO: Fix this so that only unit tests are running
test: fmtcheck
testacc: fmtcheck
TF_ACC=1 $(prefix) go test $(TEST) -v $(TESTARGS) $(run_regex) -timeout $(timeout)
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)
goimports -w -local github.com/oracle/terraform-provider-oci $(GOFMT_FILES)
@if [ -x "$$(command -v terraform)" ]; then \
terraform fmt; \
else \
echo "No terraform command found. Not running 'terraform fmt'"; \
fi
## IMPORTANT: Do not modify the following `fmtcheck` target. The following steps are a requirement of the provider release process.
## To add custom checks, use the `ocicheck` target instead.
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh' $(skip_goimports_check_flag)"
ocicheck:
@if [ -x "$$(command -v terraform)" ]; then \
echo "==> Checking terraform formatting of files"; \
terraform fmt -check=true || (echo "Terraform files are not appropriately formatted. Please run make fmt to format them." && exit 1); \
else \
echo "No terraform command found. Make sure it is installed in your PATH"; \
exit 1; \
fi
errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
vendor-status:
@govendor status
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)
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)
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)
## Additional OCI stuff that will need to be moved eventually
get: ;go get -u github.com/kardianos/govendor; go get golang.org/x/tools/cmd/goimports; go get github.com/mitchellh/gox
### `make update-version version=2.0.1`
update-version:
ifdef version
sed -i -e 's/Version = ".*"/Version = "$(version)"/g' oci/version.go && rm -f oci/version.go-e
else
@echo Err! `make update-version` requires a version argument
endif
### `make release version=2.0.1`
release: clean get
ifdef version
sed -i -e 's/Version = ".*"/Version = "$(version)"/g' oci/version.go && rm -f oci/version.go-e
gox -output ./bin/{{.OS}}_{{.Arch}}/terraform-provider-oci_v$(version)
gox -output ./bin/solaris_amd64/terraform-provider-oci_v$(version) -osarch="solaris/amd64"
else
@echo Err! `make release` requires a version argument
endif
clean: ;@rm -rf terraform-provider-oci rm -rf bin/* rm bin
zip:
@cd bin; \
zip -r windows_386.zip windows_386; \
zip -r windows_amd64.zip windows_amd64; \
tar -czvf darwin_386.tar.gz darwin_386; \
tar -czvf darwin_amd64.tar.gz darwin_amd64; \
tar -czvf freebsd_386.tar.gz freebsd_386; \
tar -czvf freebsd_amd64.tar.gz freebsd_amd64; \
tar -czvf freebsd_arm.tar.gz freebsd_arm; \
tar -czvf linux_386.tar.gz linux_386; \
tar -czvf linux_amd64.tar.gz linux_amd64; \
tar -czvf linux_arm.tar.gz linux_arm; \
tar -czvf openbsd_386.tar.gz openbsd_386; \
tar -czvf openbsd_amd64.tar.gz openbsd_amd64; \
tar -czvf solaris_amd64.tar.gz solaris_amd64
.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile website website-test