Scott Baker | 2c0ebda | 2019-05-06 16:55:47 -0700 | [diff] [blame] | 1 | ifeq ($(GOPATH),) |
| 2 | $(error Please set your GOPATH) |
| 3 | endif |
| 4 | |
| 5 | VERSION=$(shell cat $(GOPATH)/src/github.com/opencord/cordctl/VERSION) |
| 6 | GITCOMMIT=$(shell git log --pretty=format:"%h" -n 1) |
| 7 | GOVERSION=$(shell go version 2>&1 | sed -E 's/.*(go[0-9]+\.[0-9]+\.[0-9]+).*/\1/g') |
| 8 | OSTYPE=$(shell uname -s | tr A-Z a-z) |
| 9 | OSARCH=$(shell uname -p | tr A-Z a-z) |
| 10 | BUILDTIME=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") |
| 11 | |
| 12 | LDFLAGS=-ldflags \ |
| 13 | '-X "github.com/opencord/cordctl/cli/version.Version=$(VERSION)" \ |
| 14 | -X "github.com/opencord/cordctl/cli/version.GitCommit=$(GITCOMMIT)" \ |
| 15 | -X "github.com/opencord/cordctl/cli/version.GoVersion=$(GOVERSION)" \ |
| 16 | -X "github.com/opencord/cordctl/cli/version.Os=$(OSTYPE)" \ |
| 17 | -X "github.com/opencord/cordctl/cli/version.Arch=$(OSARCH)" \ |
| 18 | -X "github.com/opencord/cordctl/cli/version.BuildTime=$(BUILDTIME)"' \ |
| 19 | |
| 20 | help: |
| 21 | |
| 22 | build: dependencies |
| 23 | go build $(LDFLAGS) cmd/cordctl.go |
| 24 | |
| 25 | dependencies: |
Scott Baker | 6cf525a | 2019-05-09 12:25:08 -0700 | [diff] [blame^] | 26 | [ -d "vendor" ] || dep ensure |
Scott Baker | 2c0ebda | 2019-05-06 16:55:47 -0700 | [diff] [blame] | 27 | |
| 28 | lint: dependencies |
| 29 | find $(GOPATH)/src/github.com/opencord/cordctl -name "*.go" -not -path '$(GOPATH)/src/github.com/opencord/cordctl/vendor/*' | xargs gofmt -l |
| 30 | go vet ./... |
| 31 | dep check |
| 32 | |
| 33 | test: dependencies |
| 34 | @mkdir -p ./tests/results |
| 35 | @go test -v -coverprofile ./tests/results/go-test-coverage.out -covermode count ./... 2>&1 | tee ./tests/results/go-test-results.out ;\ |
| 36 | RETURN=$$? ;\ |
| 37 | go-junit-report < ./tests/results/go-test-results.out > ./tests/results/go-test-results.xml ;\ |
| 38 | gocover-cobertura < ./tests/results/go-test-coverage.out > ./tests/results/go-test-coverage.xml ;\ |
| 39 | exit $$RETURN |
Scott Baker | 6cf525a | 2019-05-09 12:25:08 -0700 | [diff] [blame^] | 40 | |
| 41 | clean: |
| 42 | rm -f cordctl |
| 43 | rm -rf vendor |
| 44 | rm -f Gopkg.lock |