|
| 1 | +TEST?=./... |
| 2 | +GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor) |
| 3 | +PKG_NAME=oci |
| 4 | +# Collapse with PKG_NAME once we've moved to the hashicorp repo |
| 5 | +TEST_PKG_NAME=provider |
| 6 | +WEBSITE_REPO=github.com/hashicorp/terraform-website |
| 7 | + |
| 8 | +prefix := $(if $(debug),TF_LOG=DEBUG DEBUG=true OCI_GO_SDK_DEBUG=1, ) |
| 9 | +timeout := $(if $(timeout), $(timeout), 120m) |
| 10 | +run_regex := $(if $(run), -run $(run), ) |
| 11 | +skip_goimports_check_flag := $(if $(skip_goimports_check), -s, ) |
| 12 | + |
| 13 | +default: build |
| 14 | + |
| 15 | +build: fmtcheck |
| 16 | + go install |
| 17 | + |
| 18 | +test: fmtcheck |
| 19 | + go test -i $(TEST) || exit 1 |
| 20 | + echo $(TEST) | \ |
| 21 | + xargs -t -n4 go test $(TESTARGS) -timeout=120s -parallel=4 |
| 22 | + |
| 23 | +testacc: fmtcheck |
| 24 | + TF_ACC=1 $(prefix) go test $(TEST) -v $(TESTARGS) $(run_regex) -timeout $(timeout) |
| 25 | + |
| 26 | +vet: |
| 27 | + @echo "go vet ." |
| 28 | + @go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \ |
| 29 | + echo ""; \ |
| 30 | + echo "Vet found suspicious constructs. Please check the reported constructs"; \ |
| 31 | + echo "and fix them if necessary before submitting the code for review."; \ |
| 32 | + exit 1; \ |
| 33 | + fi |
| 34 | + |
| 35 | +fmt: |
| 36 | + gofmt -w $(GOFMT_FILES) |
| 37 | + goimports -w -local github.com/oracle/terraform-provider-oci $(GOFMT_FILES) |
| 38 | + |
| 39 | +fmtcheck: |
| 40 | + @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh' $(skip_goimports_check_flag)" |
| 41 | + |
| 42 | +errcheck: |
| 43 | + @sh -c "'$(CURDIR)/scripts/errcheck.sh'" |
| 44 | + |
| 45 | +vendor-status: |
| 46 | + @govendor status |
| 47 | + |
| 48 | +test-compile: |
| 49 | + @if [ "$(TEST)" = "./..." ]; then \ |
| 50 | + echo "ERROR: Set TEST to a specific package. For example,"; \ |
| 51 | + echo " make test-compile TEST=./$(TEST_PKG_NAME)"; \ |
| 52 | + exit 1; \ |
| 53 | + fi |
| 54 | + go test -c $(TEST) $(TESTARGS) |
| 55 | + |
| 56 | +website: |
| 57 | +ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) |
| 58 | + echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." |
| 59 | + git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO) |
| 60 | +endif |
| 61 | + @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) |
| 62 | + |
| 63 | +website-test: |
| 64 | +ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) |
| 65 | + echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." |
| 66 | + git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO) |
| 67 | + # Additional steps before registration is complete |
| 68 | + ln -s ../../../../ext/providers/oci/website/docs $(GOPATH)/src/$(WEBSITE_REPO)/content/source/docs/providers/oci |
| 69 | + ln -s ../../../ext/providers/oci/website/oci.erb $(GOPATH)/src/$(WEBSITE_REPO)/content/source/layouts/oci.erb |
| 70 | +endif |
| 71 | + @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) |
| 72 | + |
| 73 | +## Additional OCI stuff that will need to be moved eventually |
| 74 | +get: ;go get -u github.com/kardianos/govendor; go get golang.org/x/tools/cmd/goimports; go get github.com/mitchellh/gox |
| 75 | + |
| 76 | +### `make update-version version=2.0.1` |
| 77 | +update-version: |
| 78 | +ifdef version |
| 79 | + sed -i -e 's/Version = ".*"/Version = "$(version)"/g' provider/version.go && rm -f provider/version.go-e |
| 80 | +else |
| 81 | + @echo Err! `make update-version` requires a version argument |
| 82 | +endif |
| 83 | + |
| 84 | +### `make release version=2.0.1` |
| 85 | +release: clean get |
| 86 | +ifdef version |
| 87 | + sed -i -e 's/Version = ".*"/Version = "$(version)"/g' provider/version.go && rm -f provider/version.go-e |
| 88 | + gox -output ./bin/{{.OS}}_{{.Arch}}/terraform-provider-oci_v$(version) |
| 89 | + gox -output ./bin/solaris_amd64/terraform-provider-oci_v$(version) -osarch="solaris/amd64" |
| 90 | +else |
| 91 | + @echo Err! `make release` requires a version argument |
| 92 | +endif |
| 93 | + |
| 94 | +clean: ;@rm -rf terraform-provider-oci rm -rf bin/* rm bin |
| 95 | + |
| 96 | +zip: |
| 97 | + @cd bin; \ |
| 98 | + zip -r windows_386.zip windows_386; \ |
| 99 | + zip -r windows_amd64.zip windows_amd64; \ |
| 100 | + tar -czvf darwin_386.tar.gz darwin_386; \ |
| 101 | + tar -czvf darwin_amd64.tar.gz darwin_amd64; \ |
| 102 | + tar -czvf freebsd_386.tar.gz freebsd_386; \ |
| 103 | + tar -czvf freebsd_amd64.tar.gz freebsd_amd64; \ |
| 104 | + tar -czvf freebsd_arm.tar.gz freebsd_arm; \ |
| 105 | + tar -czvf linux_386.tar.gz linux_386; \ |
| 106 | + tar -czvf linux_amd64.tar.gz linux_amd64; \ |
| 107 | + tar -czvf linux_arm.tar.gz linux_arm; \ |
| 108 | + tar -czvf openbsd_386.tar.gz openbsd_386; \ |
| 109 | + tar -czvf openbsd_amd64.tar.gz openbsd_amd64; \ |
| 110 | + tar -czvf solaris_amd64.tar.gz solaris_amd64 |
| 111 | + |
| 112 | +.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile website website-test |
| 113 | + |
0 commit comments