-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
92 lines (73 loc) · 2.5 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
all: lint tests binary ## Runs lint, tests, and builds the binary
PHONY: help all test coverage lint golint clean vendor docker-up docker-down unit-test
GOOS=linux
DB=location_api
DEV_DB=${DB}_dev
TEST_DB=${DB}_test
DEV_URI="postgresql://root@crdb:26257/${DEV_DB}?sslmode=disable"
TEST_URI="postgresql://root@crdb:26257/${TEST_DB}?sslmode=disable"
APP_NAME=location-api
PID_FILE=/tmp/loc.pid
help: Makefile ## Print help
@grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/:.*##/#/' | column -c 2 -t -s#
tests: | unit-tests
unit-tests: ## Runs unit tests
@echo --- Running unit tests...
@date --rfc-3339=seconds
@go test -race -cover -failfast -tags testtools -p 1 -v ./...
coverage: ## Generates coverage report
@echo --- Generating coverage report...
@date --rfc-3339=seconds
@go test -race -coverprofile=coverage.out -covermode=atomic -tags testtools -p 1 ./...
@go tool cover -func=coverage.out
@go tool cover -html=coverage.out
lint: golint ## Runs linting
golint:
@echo --- Running golint...
@date --rfc-3339=seconds
@golangci-lint run
clean: ## Clean up all the things
@echo --- Cleaning...
@date --rfc-3339=seconds
@rm -rf ./bin/
@rm -rf coverage.out
@go clean -testcache
binary: | vendor generate ## Builds the binary
@echo --- Building binary...
@date --rfc-3339=seconds
@go build -o bin/${APP_NAME} main.go
vendor: ## Vendors dependencies
@echo --- Downloading dependencies...
@date --rfc-3339=seconds
@go mod tidy
@go mod download
testclient:| background-run .testclient kill-running ## Regenerates the test client in graphclient
.testclient:
@echo --- Generating test graph client...
@date --rfc-3339=seconds
@go generate ./internal/graphclient
dev-nats: ## Initializes nats
@echo --- Initializing nats
@date --rfc-3339=seconds
@.devcontainer/scripts/nats_account.sh
generate: background-run .generate kill-running ## Generates code
.generate:
@echo --- Generating code...
@date --rfc-3339=seconds
@go generate ./...
go-run: ## Runs the app
@echo --- Running binary...
@date --rfc-3339=seconds
@go run main.go serve --dev --oidc=false
background-run: ## Runs in the app in the background
@date --rfc-3339=seconds
@if [ ! -f "${PID_FILE}" ]; then \
echo --- Running binary in the background...; \
go run main.go serve --dev --oidc=false --pid-file=${PID_FILE} & \
else \
echo --- Binary already running in the background...; \
fi
kill-running: ## Kills the running binary from pid file
@echo --- Killing background binary...
@date --rfc-3339=seconds
@kill $$(cat ${PID_FILE})