-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (51 loc) · 1.77 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
GOBIN?=${GOPATH}/bin
PACKAGES=$(shell go list ./... | grep -v ./test)
## all : fetch deps, build, test and install the application
all: deps unit-test build install
## build : build application
build:
@echo "--> Building application"
go build -race -o build/gopherpay ./cmd/gopherpay
## install : install the application to $GOPATH/bin
install:
@echo "--> Installing application"
go install ./cmd/gopherpay
## deps : fetch dependencies
deps:
@echo "--> Running dep"
go mod download
## unit-test : run unißt tests
unit-test:
@echo "--> Running unit tests"
go test -v $(PACKAGES)
## unit-test-race : run unit tests with -race flag
unit-test-race:
@echo "--> Running go test --race"
go test -v -race $(PACKAGES)
## integration-test : run integration tests
integration-test:
@echo "--> Running unit tests"
go test -race -v ./test/...
## fmt : format go files
fmt:
@echo "--> Formatting go files"
go fmt ./...
## clean : cleaning up
clean:
@echo "--> Cleaning..."
@rm -rf ./build
## docker-build : building docker image
docker-build:
@echo "--> Building docker image ..."
docker build --build-arg GO_VERSION=1.11.2 -t gopherpayment .
## docker-run : running service in docker in dev mode
docker-run:
@echo "--> Running docker container ..."
docker run --rm -p 8080:8080 --name gopherpay gopherpayment:latest
## help : show this help screen
help : Makefile
@sed -n 's/^##//p' $(MAKEFILE_LIST) | sort
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: all build install deps unit-test unit-test-race integration-test docker-build docker-run fmt clean