-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
75 lines (56 loc) · 1.73 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
SHELL := /bin/bash
export GOBIN = $(shell pwd)/bin
VERSION := 0.1 # We can use git tag for a more consistent results $(shell git tag -l $(VERSION))
BINARY := gramaddict_helper
BUILD_PATH ?= $(shell go env GOPATH)/bin
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
define HELP
$(BINARY) v$(VERSION) Makefile
=================================
## Build target
- binary: It will build $(BINARY) for the current system (by default in $(GOBIN)).
## Development targets
- lint: Runs golint and gofmt against all of the packages.
- format: Formats the codebase according to gofmt and goimports.
- unit: Runs unit tests.
- docker: Build docker image with the compiled binary.
## Release targets
- release: Releases the package to docker repository.
endef
export HELP
.DEFAULT: help
.PHONY: help
help:
@ echo "$$HELP"
include build/Makefile.deps
.PHONY: binary
binary:
@ echo "Building linux binary into $(GOBIN)/$(BINARY)"
@ echo "Binary will be based on $(OS) $(ARCH)"
@ BINARY=$(BINARY) GOOS=$(OS) GOARCH=$(ARCH) go build -o $(GOBIN)/$(BINARY)
.PHONY: release
release: docker
@ echo "------------------------------------"
@ echo "Pushing docker image to repo..."
.PHONY: docker
docker: binary
@ echo "Dockerizing..."
@ docker build -t yaniv:$(VERSION) .
.PHONY: unit
unit:
@ echo "Running unit tests for $(BINARY)..."
go test
.PHONY: lint
lint: deps
@ echo " Running linters..."
@ $(GOBIN)/golint -set_exit_status ./...
@ $(GOBIN)/golangci-lint run --timeout 2m
@ echo "Done."
.PHONY: format
format: deps
@ echo " Formatting/auto-fixing Go files..."
@ $(GOBIN)/golangci-lint run --fix
@ echo "Done."
.PHONY: clean
clean:
@ rm -rf bin