forked from onflow/flow-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
98 lines (81 loc) · 2.57 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# The short Git commit hash
SHORT_COMMIT := $(shell git rev-parse --short HEAD)
# The Git commit hash
COMMIT := $(shell git rev-parse HEAD)
# The tag of the current commit, otherwise empty
VERSION := $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
# Name of the cover profile
COVER_PROFILE := cover.out
# Disable go sum database lookup for private repos
GOPRIVATE := github.com/dapperlabs/*
# Ensure go bin path is in path (Especially for CI)
PATH := $(PATH):$(GOPATH)/bin
# OS
UNAME := $(shell uname)
GOPATH ?= $(HOME)/go
BINARY ?= ./cmd/flow/flow
.PHONY: binary
binary: $(BINARY)
.PHONY: install-tools
install-tools:
cd ${GOPATH}; \
mkdir -p ${GOPATH}; \
GO111MODULE=on go get github.com/axw/gocov/gocov; \
GO111MODULE=on go get github.com/matm/gocov-html; \
GO111MODULE=on go get github.com/sanderhahn/gozip/cmd/gozip;
.PHONY: test
test:
GO111MODULE=on go test -coverprofile=$(COVER_PROFILE) $(if $(JSON_OUTPUT),-json,) ./...
.PHONY: coverage
coverage:
ifeq ($(COVER), true)
# file has to be called index.html
gocov convert $(COVER_PROFILE) > cover.json
./cover-summary.sh
gocov-html cover.json > index.html
# coverage.zip will automatically be picked up by teamcity
gozip -c coverage.zip index.html
endif
.PHONY: ci
ci: install-tools test coverage
.PHONY: install
install:
GO111MODULE=on go install \
-trimpath \
-ldflags \
"-X github.com/onflow/flow-cli/build.commit=$(COMMIT) -X github.com/onflow/flow-cli/build.semver=$(VERSION)" \
./cmd/flow
$(BINARY):
GO111MODULE=on go build \
-trimpath \
-ldflags \
"-X github.com/onflow/flow-cli/build.commit=$(COMMIT) -X github.com/onflow/flow-cli/build.semver=$(VERSION)" \
-o $(BINARY) ./cmd/flow
.PHONY: versioned-binaries
versioned-binaries:
$(MAKE) OS=linux ARCH=amd64 ARCHNAME=x86_64 versioned-binary
$(MAKE) OS=linux ARCH=arm64 versioned-binary
$(MAKE) OS=darwin ARCH=amd64 ARCHNAME=x86_64 versioned-binary
$(MAKE) OS=darwin ARCH=arm64 versioned-binary
$(MAKE) OS=windows ARCH=amd64 ARCHNAME=x86_64 versioned-binary
.PHONY: versioned-binary
versioned-binary:
GOOS=$(OS) GOARCH=$(ARCH) $(MAKE) BINARY=./cmd/flow/flow-$(or ${ARCHNAME},${ARCHNAME},${ARCH})-$(OS)-$(VERSION) binary
.PHONY: publish
publish:
gsutil cp cmd/flow/flow-*-$(VERSION) gs://flow-cli
.PHONY: clean
clean:
rm ./cmd/flow/flow*
.PHONY: install-linter
install-linter:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${GOPATH}/bin v1.29.0
.PHONY: lint
lint:
golangci-lint run -v ./...
.PHONY: check-headers
check-headers:
@./check-headers.sh
.PHONY: check-tidy
check-tidy:
go mod tidy