github.com/hs0210/hashicorp-terraform@v0.11.12-beta1/Makefile (about) 1 VERSION?="0.3.32" 2 TEST?=./... 3 GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor) 4 WEBSITE_REPO=github.com/hashicorp/terraform-website 5 6 default: test 7 8 tools: 9 go get -u github.com/kardianos/govendor 10 go get -u golang.org/x/tools/cmd/stringer 11 go get -u golang.org/x/tools/cmd/cover 12 13 # bin generates the releaseable binaries for Terraform 14 bin: fmtcheck generate 15 @TF_RELEASE=1 sh -c "'$(CURDIR)/scripts/build.sh'" 16 17 # dev creates binaries for testing Terraform locally. These are put 18 # into ./bin/ as well as $GOPATH/bin 19 dev: fmtcheck generate 20 @TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" 21 22 quickdev: generate 23 @TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" 24 25 # Shorthand for building and installing just one plugin for local testing. 26 # Run as (for example): make plugin-dev PLUGIN=provider-aws 27 plugin-dev: generate 28 go install github.com/hashicorp/terraform/builtin/bins/$(PLUGIN) 29 mv $(GOPATH)/bin/$(PLUGIN) $(GOPATH)/bin/terraform-$(PLUGIN) 30 31 # test runs the unit tests 32 # we run this one package at a time here because running the entire suite in 33 # one command creates memory usage issues when running in Travis-CI. 34 test: fmtcheck generate 35 go list $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=2m -parallel=4 36 37 # testacc runs acceptance tests 38 testacc: fmtcheck generate 39 @if [ "$(TEST)" = "./..." ]; then \ 40 echo "ERROR: Set TEST to a specific package. For example,"; \ 41 echo " make testacc TEST=./builtin/providers/aws"; \ 42 exit 1; \ 43 fi 44 TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m 45 46 # e2etest runs the end-to-end tests against a generated Terraform binary 47 # The TF_ACC here allows network access, but does not require any special 48 # credentials since the e2etests use local-only providers such as "null". 49 e2etest: generate 50 TF_ACC=1 go test -v ./command/e2etest 51 52 test-compile: fmtcheck generate 53 @if [ "$(TEST)" = "./..." ]; then \ 54 echo "ERROR: Set TEST to a specific package. For example,"; \ 55 echo " make test-compile TEST=./builtin/providers/aws"; \ 56 exit 1; \ 57 fi 58 go test -c $(TEST) $(TESTARGS) 59 60 # testrace runs the race checker 61 testrace: fmtcheck generate 62 TF_ACC= go test -race $(TEST) $(TESTARGS) 63 64 cover: 65 @go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \ 66 go get -u golang.org/x/tools/cmd/cover; \ 67 fi 68 go test $(TEST) -coverprofile=coverage.out 69 go tool cover -html=coverage.out 70 rm coverage.out 71 72 # generate runs `go generate` to build the dynamically generated 73 # source files. 74 generate: 75 @which stringer > /dev/null; if [ $$? -ne 0 ]; then \ 76 go get -u golang.org/x/tools/cmd/stringer; \ 77 fi 78 go generate ./... 79 @go fmt command/internal_plugin_list.go > /dev/null 80 81 fmt: 82 gofmt -w $(GOFMT_FILES) 83 84 fmtcheck: 85 @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" 86 87 vendor-status: 88 @govendor status 89 90 website: 91 ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) 92 echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." 93 git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO) 94 endif 95 $(eval WEBSITE_PATH := $(GOPATH)/src/$(WEBSITE_REPO)) 96 @echo "==> Starting core website in Docker..." 97 @docker run \ 98 --interactive \ 99 --rm \ 100 --tty \ 101 --publish "4567:4567" \ 102 --publish "35729:35729" \ 103 --volume "$(shell pwd)/website:/website" \ 104 --volume "$(shell pwd):/ext/terraform" \ 105 --volume "$(WEBSITE_PATH)/content:/terraform-website" \ 106 --volume "$(WEBSITE_PATH)/content/source/assets:/website/docs/assets" \ 107 --volume "$(WEBSITE_PATH)/content/source/layouts:/website/docs/layouts" \ 108 --workdir /terraform-website \ 109 hashicorp/middleman-hashicorp:${VERSION} 110 111 website-test: 112 ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) 113 echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." 114 git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO) 115 endif 116 $(eval WEBSITE_PATH := $(GOPATH)/src/$(WEBSITE_REPO)) 117 @echo "==> Testing core website in Docker..." 118 -@docker stop "tf-website-core-temp" 119 @docker run \ 120 --detach \ 121 --rm \ 122 --name "tf-website-core-temp" \ 123 --publish "4567:4567" \ 124 --volume "$(shell pwd)/website:/website" \ 125 --volume "$(shell pwd):/ext/terraform" \ 126 --volume "$(WEBSITE_PATH)/content:/terraform-website" \ 127 --volume "$(WEBSITE_PATH)/content/source/assets:/website/docs/assets" \ 128 --volume "$(WEBSITE_PATH)/content/source/layouts:/website/docs/layouts" \ 129 --workdir /terraform-website \ 130 hashicorp/middleman-hashicorp:${VERSION} 131 $(WEBSITE_PATH)/content/scripts/check-links.sh "http://127.0.0.1:4567" "/" "/docs/providers/*" 132 @docker stop "tf-website-core-temp" 133 134 # disallow any parallelism (-j) for Make. This is necessary since some 135 # commands during the build process create temporary files that collide 136 # under parallel conditions. 137 .NOTPARALLEL: 138 139 .PHONY: bin cover default dev e2etest fmt fmtcheck generate plugin-dev quickdev test-compile test testacc testrace tools vendor-status website website-test