forked from mattermost/mmctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (55 loc) · 1.61 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
.PHONY: vendor docs
GO_PACKAGES=$(shell go list ./...)
GO ?= $(shell command -v go 2> /dev/null)
BUILD_HASH = $(shell git rev-parse HEAD)
LDFLAGS += -X "github.com/mattermost/mmctl/commands.BuildHash=$(BUILD_HASH)"
all: build
build: vendor check
go build -ldflags '$(LDFLAGS)' -mod=vendor
install: vendor check
go install -ldflags '$(LDFLAGS)' -mod=vendor
package: vendor check
mkdir -p build
@echo Build Linux amd64
env GOOS=linux GOARCH=amd64 go build -mod=vendor
tar cf build/linux_amd64.tar mmctl
@echo Build OSX amd64
env GOOS=darwin GOARCH=amd64 go build -mod=vendor
tar cf build/darwin_amd64.tar mmctl
@echo Build Windows amd64
env GOOS=windows GOARCH=amd64 go build -mod=vendor
zip build/windows_amd64.zip mmctl.exe
rm mmctl mmctl.exe
gofmt:
@echo Running gofmt
@for package in $(GO_PACKAGES); do \
echo "Checking "$$package; \
files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \
if [ "$$files" ]; then \
gofmt_output=$$(gofmt -d -s $$files 2>&1); \
if [ "$$gofmt_output" ]; then \
echo "$$gofmt_output"; \
echo "Gofmt failure"; \
exit 1; \
fi; \
fi; \
done
@echo Gofmt success
govet:
@echo Running govet
$(GO) get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
$(GO) vet $(GO_PACKAGES)
$(GO) vet -vettool=$(GOPATH)/bin/shadow $(GO_PACKAGES)
@echo Govet success
test:
@echo Running tests
$(GO) test -race -v $(GO_PACKAGES)
check: gofmt govet
vendor:
go mod vendor
go mod tidy
mocks:
mockgen -destination=mocks/client_mock.go -package=mocks github.com/mattermost/mmctl/client Client
docs:
rm -rf docs
go run -mod=vendor mmctl.go docs