-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
83 lines (68 loc) · 1.95 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
PROJECTNAME := $(shell basename "$(PWD)")
PACKAGES := $(shell go list ./... | grep -v vendor)
# Go related variables.
PROJECTROOT := $(shell pwd)
GOBIN := $(PROJECTROOT)/bin
GOFILES := $(PROJECTROOT)/*.go
# Shell script related variables.
UTILDIR := $(PROJECTROOT)/scripts/utils
SPINNER := $(UTILDIR)/spinner.sh
BUILDIR := $(PROJECTROOT)/scripts/build
# Make is verbose in Linux. Make it silent.
MAKEFLAGS += --silent
.PHONY: default
default: help
## install: Install missing dependencies
install:
@printf "🔨 Installing project dependencies to vendor\n"
@GOBIN=$(GOBIN) go get ./... && go mod vendor
@printf "👍 Done\n"
## build: Build the project binary
build:
@printf "🔨 Building binary $(GOBIN)/$(PROJECTNAME)\n"
@go build -o $(GOBIN)/$(PROJECTNAME) $(GOFILES)
@printf "👍 Done\n"
## tools: Install development tools
tools:
@$(BUILDIR)/install_fresh.sh
@$(BUILDIR)/install_golint.sh
## release: Build release binaries
release:
@printf "🔨 Building Release Binaries\n"
@rm -rf releases/
go run $(BUILDIR)/release.go $(VERSION)
@printf "👍 Done\n"
## start: Start in development mode with hot-reload enabled
start: tools
@$(PROJECTROOT)/bin/fresh
## clean: Clean build files
clean:
@printf "🔨 Cleaning build cache\n"
@go clean $(PACKAGES)
@printf "👍 Done\n"
@-rm $(GOBIN)/$(PROJECTNAME) 2>/dev/null
## fmt: Format entire codebase
fmt:
@printf "🔨 Formatting\n"
@gofmt -s -w .
@printf "👍 Done\n"
## vet: Vet entire codebase
vet:
@printf "🔨 Vetting\n"
@go vet $(PACKAGES)
@printf "👍 Done\n"
## lint: Check codebase for style mistakes
lint:
@printf "🔨 Linting\n"
@golint -set_exit_status $(PACKAGES)
@printf "👍 Done\n"
## test: Run tests
test:
@printf "🔨 Testing\n"
@go test -race -coverprofile=coverage.txt -covermode=atomic
@printf "👍 Done\n"
## help: Display this help
help: Makefile
@printf "\n Gasper: Your cloud in a binary\n\n"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@printf ""