-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (85 loc) · 3.17 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
105
106
107
108
109
110
111
112
113
check-var-defined = $(if $(strip $($1)),,$(error "$1" is not defined))
# Export all variables to child processes
.EXPORT_ALL_VARIABLES:
NO_COLOR=\033[0m
OK_COLOR=\033[32;01m
ERROR_COLOR=\033[31;01m
WARN_COLOR=\033[33;01m
AUTOGENERATED_WARNING='Autogenerated from `make mockery` do not edit manually'
GO_PACKAGES = $(shell go list ./... | grep -v vendor | grep -v test | grep -v pkg | grep -v testutil | grep -v version)
GO_PACKAGES_NO_PREFIX=$(shell echo ${GO_PACKAGES//github.com\/maxheckel\//})
GO_FILES = $(shell find . -name "*.go" | grep -v vendor | grep -v mock | uniq)
LOCAL_DB_NAME := covid_county
LOCAL_DB_PORT := 9999
# The binary to build (just the basename).
BIN := covid_county
# This repo's root import path (under GOPATH).
PKG := github.com/maxheckel/covid_county
SRC_DIRS := cmd pkg internal # directories which hold app source (not vendored)
.PHONY: clean
clean:
rm -f .build-* .container-* .push-*
.PHONY: docker-run-api
docker-api: docker-build
@echo "$(OK_COLOR)==> Starting local api via docker$(NO_COLOR)"
@./scripts/docker-compose.sh kill -s SIGINT app
@./scripts/docker-compose.sh rm -f -v app
@./scripts/docker-compose.sh build app
@./scripts/docker-compose.sh up -d app
docker-build:
@echo "$(OK_COLOR)==> Building go binary for docker image: $(NO_COLOR)"
CGO_ENABLED=0 GOOS=linux go build -o ./infra/bin/covid_county ./cmd/covid_county
.PHONY: docker-db
docker-db:
@echo "$(OK_COLOR)==> Starting local db via docker$(NO_COLOR)"
@./scripts/docker-compose.sh kill -s SIGINT db
@./scripts/docker-compose.sh rm -f -v db
@./scripts/docker-compose.sh build db
@./scripts/docker-compose.sh up -d db
.PHONY: docker-logs
docker-logs: docker-run
@echo "$(OK_COLOR)==> Running in docker: $(NO_COLOR)"
@./scripts/docker-compose.sh logs -f --tail 10
.PHONY: docker-run
docker-run: docker-build
@echo "$(OK_COLOR)==> Running in docker: $(NO_COLOR)"
@./scripts/docker-compose.sh kill -s SIGINT
@./scripts/docker-compose.sh rm -f -v
@./scripts/docker-compose.sh build
@./scripts/docker-compose.sh up -d
.PHONY: docker-watch
docker-watch: docker-build
@echo "$(OK_COLOR)==> Running in docker: $(NO_COLOR)"
@./scripts/docker-compose-watch.sh kill -s SIGINT
@./scripts/docker-compose-watch.sh rm -f -v
@./scripts/docker-compose-watch.sh build
@./scripts/docker-compose-watch.sh up
.PHONY: docker-down
docker-down:
@echo "$(OK_COLOR)==> Stopping docker: $(NO_COLOR)"
@./scripts/docker-compose.sh down
.PHONY: format
format:
@echo "$(OK_COLOR)==> Formatting$(NO_COLOR)"
@goimports -l -w $(GO_FILES)
.PHONY: init
init:
@echo "$(OK_COLOR)===> Setup dependencies$(NO_COLOR)"
IMPORTED_PACKAGES="$(IMPORTED_PACKAGES)" ./scripts/init.sh
.PHONY: lint
lint:
@echo "$(OK_COLOR)==> Linting$(NO_COLOR)"
golangci-lint run $(GO_PACKAGES_NO_PREFIX)
lint-fix:
@echo "$(OK_COLOR)==> Fixing lint issues$(NO_COLOR)"
golangci-lint run --fix $(GO_PACKAGES_NO_PREFIX)
mocks:
@echo "$(OK_COLOR)==> Generating Mocks$(NO_COLOR)"
rm -rf ./testutil/externalmock/*
go mod vendor
mockery --all --inpackage --dir covid_count --note $(AUTOGENERATED_WARNING)
# recommended test command
.PHONY: test
test:
@echo "$(OK_COLOR)==> Testing $(NO_COLOR)"
gotest -v -race -coverprofile=coverage.out $(GO_PACKAGES)