forked from cristianoliveira/ergo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (67 loc) · 3.06 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
NO_COLOR=\33[0m
OK_COLOR=\33[32m
ERROR_COLOR=\033[31m
WARN_COLOR=\33[33m
.PHONY: all start build test test-integration coverage deps help fmt vet lint tools
VERSION=`git describe --tag --always`
LDFLAGS_f1=-ldflags "-w -s -X main.VERSION=${VERSION}"
help:
@(echo "${WARN_COLOR}Usage:${NO_COLOR}")
@(echo "${OK_COLOR}make all${NO_COLOR} Run the tests and build the executable")
@(echo "${OK_COLOR}make help${NO_COLOR} Show this help")
@(echo "${OK_COLOR}make build-darwin-arm${NO_COLOR} Builds the executable for osx arm")
@(echo "${OK_COLOR}make build-linux-arm${NO_COLOR} Builds the executable for linux arm")
@(echo "${OK_COLOR}make build-windows-i386${NO_COLOR} Builds the executable for windows")
@(echo "${OK_COLOR}make bump-version${NO_COLOR} Write the new version for latter use")
@(echo "${OK_COLOR}make build${NO_COLOR} Builds the executable for current system")
@(echo "${OK_COLOR}make start${NO_COLOR} Starts ergo")
@(echo "${OK_COLOR}make fmt${NO_COLOR} Run gofmt on the source code")
@(echo "${OK_COLOR}make vet${NO_COLOR} Run go vet on the source code")
@(echo "${OK_COLOR}make test${NO_COLOR} Run the unit tests")
@(echo "${OK_COLOR}make test-integration${NO_COLOR} Run the integration tests")
@(echo "${OK_COLOR}make watch${NO_COLOR} Run funzzy watch")
@(echo "${OK_COLOR}make clean${NO_COLOR} Remove the compiled executables")
@(echo "${OK_COLOR}make deps${NO_COLOR} Get the dependencies needed to build the project")
all: deps test build test-integration bump-version
build-darwin-arm:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/darwin/ergo
build-linux-arm:
GOOS=linux GOARCH=arm64 go build -o bin/linux/ergo
build-windows-i386:
GOOS=windows GOARCH=386 go build -o bin/win/ergo.exe
bump-version:
@git tag --sort=committerdate | tail -n 1 > .version
cat .version
build: bump-version
@go build ${LDFLAGS_f1} -o bin/ergo
start:
@go run main.go run
tools:
@(go get github.com/golang/lint)
fmt:
@(echo "${OK_COLOR}Running fmt ...${NO_COLOR}")
@([ $$(gofmt -l . | wc -l) != 0 ] && \
echo "${WARN_COLOR}The following files are not correctly formated:${NO_COLOR}" && \
echo "${ERROR_COLOR}" && gofmt -l . && \
echo "${NO_COLOR}" && exit 1 || exit 0)
vet:
@(echo "${OK_COLOR}Running vet ...${NO_COLOR}")
go vet ./...
lint: tools
@(echo "${OK_COLOR}Running lint ...${NO_COLOR}")
@(export PATH=$$PATH:$$GOPATH/bin && [ $$(golint ./... | wc -l) != 0 ] && \
echo "${WARN_COLOR}Lint says the following files are not ok:${NO_COLOR}" && \
echo "${ERROR_COLOR}" && golint ./... && \
echo "${NO_COLOR}" && exit 1 || exit 0)
coverage:
@sh ./ci/coverage.sh
test: fmt vet lint
@(go test -v ./...)
test-integration: build
go test -tags=integration -v ./...
watch:
funzzy watch
clean:
rm bin/ergo
deps:
@go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v ergo | go get