-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
83 lines (68 loc) · 1.88 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
NAME = go-springfield-bank
COMMAND_HANDLER ?= serverd
VERSION ?= dev
OS ?= linux
.PHONY: dev-up
dev-up:
@echo "Starting dev deps"
docker-compose -f deployments/docker-compose-dev.yml up -d
.PHONY: dev-down
dev-down:
@echo "Shutting dev deps down"
docker-compose -f deployments/docker-compose-dev.yml down
.PHONY: start
start:
@echo "Starting"
docker-compose -f deployments/docker-compose.yml up -d --build
.PHONY: stop
stop:
@echo "Stopping"
docker-compose -f deployments/docker-compose.yml down
.PHONY: setup
setup:
@go mod download
@echo "Installing tools"
@go install github.com/swaggo/swag/cmd/swag@latest
@go install github.com/rakyll/gotest@latest
@go install github.com/resotto/gochk/cmd/gochk@latest
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go mod tidy
.PHONY: clean
clean:
@echo "Cleaning releases"
GOOS=${OS} go clean -i -x ./...
rm -f build/${COMMAND_HANDLER}
rm -f dist/${COMMAND_HANDLER}
rm -f coverage.txt
.PHONY: test
test:
@echo "Running tests"
gotest -race -failfast -v ./...
.PHONY: test-coverage
test-coverage:
@echo "Running coverage tests"
gotest -race -failfast -coverprofile=coverage.out -covermode=atomic ./...
.PHONY: compile
compile: clean
@echo "Building "${COMMAND_HANDLER}
env GOOS=${OS} GOARCH=amd64 go build -v -o dist/${COMMAND_HANDLER} cmd/${COMMAND_HANDLER}/main.go
@echo "Binary generated at dist/"${COMMAND_HANDLER}
.PHONY: build
build: clean
@echo "Building Docker image"
docker build -t ${NAME}-${COMMAND_HANDLER}:${VERSION} build -f build/Dockerfile
.PHONY: generate
generate:
@echo "Generating Go files"
go generate ./...
swag init -g cmd/${COMMAND_HANDLER}/main.go -o api
.PHONY: lint
lint:
@echo "Running golangci-lint"
golangci-lint run --fix ./...
.PHONY: archlint
archlint:
@echo "Running architecture linter(gochk)"
gochk -e -c ./gochk-arch-lint.json
.PHONY: pre-push
pre-push: lint archlint test