forked from infratographer/load-balancer-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (73 loc) · 2.41 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=load_balancer_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=loadbalancer-api
PID_FILE=/tmp/lba.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 -Iseconds
@go test -race -cover -failfast -tags testtools -p 1 -v ./...
coverage: ## Generates coverage report
@echo --- Generating coverage report...
@date -Iseconds
@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 -Iseconds
@golangci-lint run
clean: ## Clean up all the things
@echo --- Cleaning...
@date -Iseconds
@rm -rf ./bin/
@rm -rf coverage.out
@go clean -testcache
binary: | vendor generate ## Builds the binary
@echo --- Building binary...
@date -Iseconds
@go build -o bin/${APP_NAME} main.go
vendor: ## Vendors dependencies
@echo --- Downloading dependencies...
@date -Iseconds
@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 -Iseconds
@go generate ./internal/graphclient
dev-nats: ## Initializes nats
@echo --- Initializing nats
@date -Iseconds
@.devcontainer/scripts/nats_account.sh
generate: background-run .generate kill-running ## Generates code
.generate:
@echo --- Generating code...
@date -Iseconds
@go generate ./...
go-run: ## Runs the app
@echo --- Running binary...
@date -Iseconds
@go run main.go serve --dev --oidc=false
background-run: ## Runs in the app in the background
@date -Iseconds
@if [ ! -f "${PID_FILE}" ]; then \
echo --- Running binary in the background...; \
go run main.go serve --pid-file=${PID_FILE} --dev --oidc=false & \
else \
echo --- Binary already running in the background...; \
fi
kill-running: ## Kills the running binary from pid file
@echo --- Killing background binary...
@date -Iseconds
@kill $$(cat ${PID_FILE})