github.com/hooklift/terraform@v0.11.0-beta1.0.20171117000744-6786c1361ffe/Makefile (about)

     1  TEST?=./...
     2  GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
     3  
     4  default: test vet
     5  
     6  tools:
     7  	go get -u github.com/kardianos/govendor
     8  	go get -u golang.org/x/tools/cmd/stringer
     9  	go get -u golang.org/x/tools/cmd/cover
    10  
    11  # bin generates the releaseable binaries for Terraform
    12  bin: fmtcheck generate
    13  	@TF_RELEASE=1 sh -c "'$(CURDIR)/scripts/build.sh'"
    14  
    15  # dev creates binaries for testing Terraform locally. These are put
    16  # into ./bin/ as well as $GOPATH/bin
    17  dev: fmtcheck generate
    18  	@TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'"
    19  
    20  quickdev: generate
    21  	@TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'"
    22  
    23  # Shorthand for building and installing just one plugin for local testing.
    24  # Run as (for example): make plugin-dev PLUGIN=provider-aws
    25  plugin-dev: generate
    26  	go install github.com/hashicorp/terraform/builtin/bins/$(PLUGIN)
    27  	mv $(GOPATH)/bin/$(PLUGIN) $(GOPATH)/bin/terraform-$(PLUGIN)
    28  
    29  # test runs the unit tests
    30  # we run this one package at a time here because running the entire suite in
    31  # one command creates memory usage issues when running in Travis-CI.
    32  test: fmtcheck generate
    33  	go test -i $(TEST) || exit 1
    34  	go list $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=60s -parallel=4
    35  
    36  # testacc runs acceptance tests
    37  testacc: fmtcheck generate
    38  	@if [ "$(TEST)" = "./..." ]; then \
    39  		echo "ERROR: Set TEST to a specific package. For example,"; \
    40  		echo "  make testacc TEST=./builtin/providers/aws"; \
    41  		exit 1; \
    42  	fi
    43  	TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
    44  
    45  # e2etest runs the end-to-end tests against a generated Terraform binary
    46  # The TF_ACC here allows network access, but does not require any special
    47  # credentials since the e2etests use local-only providers such as "null".
    48  e2etest: generate
    49  	TF_ACC=1 go test -v ./command/e2etest
    50  
    51  test-compile: fmtcheck generate
    52  	@if [ "$(TEST)" = "./..." ]; then \
    53  		echo "ERROR: Set TEST to a specific package. For example,"; \
    54  		echo "  make test-compile TEST=./builtin/providers/aws"; \
    55  		exit 1; \
    56  	fi
    57  	go test -c $(TEST) $(TESTARGS)
    58  
    59  # testrace runs the race checker
    60  testrace: fmtcheck generate
    61  	TF_ACC= go test -race $(TEST) $(TESTARGS)
    62  
    63  cover:
    64  	@go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
    65  		go get -u golang.org/x/tools/cmd/cover; \
    66  	fi
    67  	go test $(TEST) -coverprofile=coverage.out
    68  	go tool cover -html=coverage.out
    69  	rm coverage.out
    70  
    71  # vet runs the Go source code static analysis tool `vet` to find
    72  # any common errors.
    73  vet:
    74  	@echo 'go vet ./...'
    75  	@go vet ./... ; if [ $$? -eq 1 ]; then \
    76  		echo ""; \
    77  		echo "Vet found suspicious constructs. Please check the reported constructs"; \
    78  		echo "and fix them if necessary before submitting the code for review."; \
    79  		exit 1; \
    80  	fi
    81  
    82  # generate runs `go generate` to build the dynamically generated
    83  # source files.
    84  generate:
    85  	@which stringer > /dev/null; if [ $$? -ne 0 ]; then \
    86  	  go get -u golang.org/x/tools/cmd/stringer; \
    87  	fi
    88  	go generate ./...
    89  	@go fmt command/internal_plugin_list.go > /dev/null
    90  
    91  fmt:
    92  	gofmt -w $(GOFMT_FILES)
    93  
    94  fmtcheck:
    95  	@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
    96  
    97  vendor-status:
    98  	@govendor status
    99  
   100  # disallow any parallelism (-j) for Make. This is necessary since some
   101  # commands during the build process create temporary files that collide
   102  # under parallel conditions.
   103  .NOTPARALLEL:
   104  
   105  .PHONY: bin cover default dev e2etest fmt fmtcheck generate plugin-dev quickdev test-compile test testacc testrace tools vendor-status vet