github.com/kimor79/packer@v0.8.7-0.20151221212622-d507b18eb4cf/Makefile (about)

     1  TEST?=./...
     2  # Get the current full sha from git
     3  GITSHA:=$(shell git rev-parse HEAD)
     4  # Get the current local branch name from git (if we can, this may be blank)
     5  GITBRANCH:=$(shell git symbolic-ref --short HEAD 2>/dev/null)
     6  
     7  default: test dev
     8  
     9  ci: deps test
    10  
    11  release: updatedeps test releasebin
    12  
    13  bin: deps
    14  	@echo "WARN: 'make bin' is for debug / test builds only. Use 'make release' for release builds."
    15  	@sh -c "$(CURDIR)/scripts/build.sh"
    16  
    17  releasebin: deps
    18  	@grep 'const VersionPrerelease = ""' version.go > /dev/null ; if [ $$? -ne 0 ]; then \
    19  		echo "ERROR: You must remove prerelease tags from version.go prior to release."; \
    20  		exit 1; \
    21  	fi
    22  	@sh -c "$(CURDIR)/scripts/build.sh"
    23  
    24  deps:
    25  	go get -v -d ./...
    26  
    27  dev: deps
    28  	@grep 'const VersionPrerelease = ""' version.go > /dev/null ; if [ $$? -eq 0 ]; then \
    29  		echo "ERROR: You must add prerelease tags to version.go prior to making a dev build."; \
    30  		exit 1; \
    31  	fi
    32  	@PACKER_DEV=1 sh -c "$(CURDIR)/scripts/build.sh"
    33  
    34  # generate runs `go generate` to build the dynamically generated
    35  # source files.
    36  generate: deps
    37  	go generate ./...
    38  
    39  test: deps
    40  	go test $(TEST) $(TESTARGS) -timeout=15s | tee packer-test.log
    41  	@go vet 2>/dev/null ; if [ $$? -eq 3 ]; then \
    42  		go get golang.org/x/tools/cmd/vet; \
    43  	fi
    44  	@go vet $(TEST) ; if [ $$? -eq 1 ]; then \
    45  		echo "ERROR: Vet found problems in the code."; \
    46  		exit 1; \
    47  	fi
    48  
    49  # testacc runs acceptance tests
    50  testacc: deps generate
    51  	@echo "WARN: Acceptance tests will take a long time to run and may cost money. Ctrl-C if you want to cancel."
    52  	PACKER_ACC=1 go test -v $(TEST) $(TESTARGS) -timeout=45m | tee packer-test-acc.log
    53  
    54  testrace: deps
    55  	go test -race $(TEST) $(TESTARGS) -timeout=15s | tee packer-test-race.log
    56  
    57  # `go get -u` causes git to revert packer to the master branch. This causes all
    58  # kinds of headaches. We record the git sha when make starts try to correct it
    59  # if we detect dift. DO NOT use `git checkout -f` for this because it will wipe
    60  # out your changes without asking.
    61  updatedeps:
    62  	@echo "INFO: Currently on $(GITBRANCH) ($(GITSHA))"
    63  	@git diff-index --quiet HEAD ; if [ $$? -ne 0 ]; then \
    64  		echo "ERROR: Your git working tree has uncommitted changes. updatedeps will fail. Please stash or commit your changes first."; \
    65  		exit 1; \
    66  	fi
    67  	go get -u github.com/mitchellh/gox
    68  	go get -u golang.org/x/tools/cmd/stringer
    69  	go list ./... \
    70  		| xargs go list -f '{{join .Deps "\n"}}' \
    71  		| grep -v github.com/mitchellh/packer \
    72  		| grep -v '/internal/' \
    73  		| sort -u \
    74  		| xargs go get -f -u -v -d ; if [ $$? -ne 0 ]; then \
    75  		echo "ERROR: go get failed. Your git branch may have changed; you were on $(GITBRANCH) ($(GITSHA))."; \
    76  	fi
    77  	@if [ "$(GITBRANCH)" != "" ]; then git checkout -q $(GITBRANCH); else git checkout -q $(GITSHA); fi
    78  	@if [ `git rev-parse HEAD` != "$(GITSHA)" ]; then \
    79  		echo "ERROR: git checkout has drifted and we weren't able to correct it. Was $(GITBRANCH) ($(GITSHA))"; \
    80  		exit 1; \
    81  	fi
    82  	@echo "INFO: Currently on $(GITBRANCH) ($(GITSHA))"
    83  
    84  .PHONY: bin checkversion ci default deps generate releasebin test testacc testrace updatedeps