github.com/leg100/ots@v0.0.7-0.20210919080622-034055ced4bd/Makefile (about) 1 VERSION = $(shell git describe --tags --dirty --always) 2 GIT_COMMIT = $(shell git rev-parse HEAD) 3 LD_FLAGS = " \ 4 -X '.Version=$(VERSION)' \ 5 -X '.Commit=$(GIT_COMMIT)' \ 6 " \ 7 8 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) 9 ifeq (,$(shell go env GOBIN)) 10 GOBIN=$(shell go env GOPATH)/bin 11 else 12 GOBIN=$(shell go env GOBIN) 13 endif 14 15 .PHONY: go-tfe-tests 16 go-tfe-tests: build 17 ./hack/harness.bash ./hack/go-tfe-tests.bash 18 19 .PHONY: e2e 20 e2e: build 21 ./hack/harness.bash go test ./e2e -failfast 22 23 .PHONY: unit 24 unit: 25 go test $$(go list ./... | grep -v e2e) 26 27 .PHONY: build 28 build: 29 go build -o _build/ -ldflags $(LD_FLAGS) ./... 30 chmod -R +x _build/* 31 32 .PHONY: install 33 install: 34 go install -ldflags $(LD_FLAGS) ./... 35 36 .PHONY: install-latest-release 37 install-latest-release: 38 { \ 39 set -e ;\ 40 ZIP_FILE=$$(tempfile --prefix=ots --suffix=.zip) ;\ 41 RELEASE_URL=$$(curl -s https://api.github.com/repos/leg100/ots/releases/latest | \ 42 jq -r '.assets[] | select(.name | test(".*_linux_amd64.zip$$")) | .browser_download_url') ;\ 43 curl -Lo $$ZIP_FILE $$RELEASE_URL ;\ 44 unzip -o -d $(GOBIN) $$ZIP_FILE ;\ 45 } 46 47 # Run go fmt against code 48 .PHONY: fmt 49 fmt: 50 go fmt ./... 51 52 # Run go vet against code 53 .PHONY: vet 54 vet: 55 go vet ./...