forked from garethr/kubetest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
135 lines (96 loc) · 3.66 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
NAME=kubetest
IMAGE_NAME=garethr/$(NAME)
PACKAGE_NAME=github.com/garethr/$(NAME)
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
TAG=$$(git describe --abbrev=0 --tags)
TAG=0.1.0
LDFLAGS += -X "$(PACKAGE_NAME)/version.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
LDFLAGS += -X "$(PACKAGE_NAME)/version.BuildVersion=$(shell git describe --abbrev=0 --tags)"
LDFLAGS += -X "$(PACKAGE_NAME)/version.BuildSHA=$(shell git rev-parse HEAD)"
# Strip debug information
LDFLAGS += -s
ifeq ($(OS),Windows_NT)
suffix := .exe
endif
all: build
$(GOPATH)/bin/glide$(suffix):
go get github.com/Masterminds/glide
$(GOPATH)/bin/golint$(suffix):
go get github.com/golang/lint/golint
$(GOPATH)/bin/goveralls$(suffix):
go get github.com/mattn/goveralls
$(GOPATH)/bin/errcheck$(suffix):
go get -u github.com/kisielk/errcheck
.bats:
git clone --depth 1 https://github.com/sstephenson/bats.git .bats
glide.lock: glide.yaml $(GOPATH)/bin/glide$(suffix)
glide update
@touch $@
vendor: glide.lock
glide install
@touch $@
check: vendor $(GOPATH)/bin/errcheck$(suffix)
errcheck
releases:
mkdir -p releases
bin/linux/amd64:
mkdir -p bin/linux/amd64
bin/windows/amd64:
mkdir -p bin/windows/amd64
bin/windows/386:
mkdir -p bin/windows/386
bin/darwin/amd64:
mkdir -p bin/darwin/amd64
build: darwin linux windows
darwin: vendor releases bin/darwin/amd64
env GOOS=darwin GOAARCH=amd64 go build -ldflags '$(LDFLAGS)' -v -o $(CURDIR)/bin/darwin/amd64/$(NAME)
tar -C bin/darwin/amd64 -cvzf releases/$(NAME)-darwin-amd64.tar.gz $(NAME)
linux: vendor releases bin/linux/amd64
env GOOS=linux GOAARCH=amd64 go build -ldflags '$(LDFLAGS)' -v -o $(CURDIR)/bin/linux/amd64/$(NAME)
tar -C bin/linux/amd64 -cvzf releases/$(NAME)-linux-amd64.tar.gz $(NAME)
windows: windows-64 windows-32
windows-64: vendor releases bin/windows/amd64
env GOOS=windows GOAARCH=amd64 go build -ldflags '$(LDFLAGS)' -v -o $(CURDIR)/bin/windows/amd64/$(NAME).exe
tar -C bin/windows/amd64 -cvzf releases/$(NAME)-windows-amd64.tar.gz $(NAME).exe
cd bin/windows/amd64 && zip ../../../releases/$(NAME)-windows-amd64.zip $(NAME).exe
windows-32: vendor releases bin/windows/386
env GOOS=windows GOAARCH=386 go build -ldflags '$(LDFLAGS)' -v -o $(CURDIR)/bin/windows/386/$(NAME).exe
tar -C bin/windows/386 -cvzf releases/$(NAME)-windows-386.tar.gz $(NAME).exe
cd bin/windows/386 && zip ../../../releases/$(NAME)-windows-386.zip $(NAME).exe
lint: $(GOPATH)/bin/golint$(suffix)
golint
docker:
docker build -t $(IMAGE_NAME):$(TAG) .
docker tag $(IMAGE_NAME):$(TAG) $(IMAGE_NAME):latest
publish: docker
docker push $(IMAGE_NAME):$(TAG)
docker push $(IMAGE_NAME):latest
vet:
go vet `glide novendor`
test: vendor vet lint check
go test -v -cover `glide novendor`
coveralls: vendor $(GOPATH)/bin/goveralls$(suffix)
goveralls -service=travis-ci
watch:
ls */*.go | entr make test
acceptance: .bats
env PATH=./.bats/bin:$$PATH:./bin/darwin/amd64 ./acceptance.bats
cover:
go test -v ./$(NAME) -coverprofile=coverage.out
go tool cover -html=coverage.out
rm coverage.out
clean:
rm -fr releases bin
fmt:
gofmt -w $(GOFMT_FILES)
checksum-windows-386:
cd releases && checksum -f $(NAME)-windows-386.zip -t=sha256
checksum-windows-amd64:
cd releases && checksum -f $(NAME)-windows-amd64.zip -t=sha256
checksum-darwin:
cd releases && checksum -f $(NAME)-darwin-amd64.tar.gz -t=sha256
chocolatey/$(NAME)/$(NAME).$(TAG).nupkg: chocolatey/$(NAME)/$(NAME).nuspec
cd chocolatey/$(NAME) && choco pack
choco:
cd chocolatey/$(NAME) && choco push $(NAME).$(TAG).nupkg -s https://chocolatey.org/
.PHONY: fmt clean cover acceptance lint docker test vet watch windows linux darwin build check checksum-windows-386 checksum-windows-amd64 checksum-darwin choco