-
Notifications
You must be signed in to change notification settings - Fork 59
/
Makefile
104 lines (77 loc) · 3.3 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
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 setup-golant
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 install golang.org/x/lint/golint)
fmt: tools
@(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: tools
@(echo "${OK_COLOR}Running vet ...${NO_COLOR}")
go vet ./...
lint: tools
@(echo "Running lint ...")
@(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:
@(go test -v ./...)
test-integration: build
go test -tags=integration -v ./...
watch:
funzzy watch
clean:
rm bin/ergo
setup-golant:
gvm use $(cat .gvmrc)
deps:
@go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v ergo | go get
.PHONY: nix-shell nix-build nix-check nix-hash-reset
nix-check:
@nix flake check
nix-build:
@nix build .#ergoProxyNigthly
@nix build .#ergoProxy
nix-hash-reset:
@sed -i '' 's/sha256-.*=//g' nix/package.nix