-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
86 lines (68 loc) · 2.29 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
all: lint test
PHONY: help all test coverage lint golint clean vendor docker-up docker-down unit-test
GOOS=linux
DB=ipam
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=ipam-api
PID_FILE=/tmp/${APP_NAME}.pid
help: Makefile ## Print help
@grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/:.*##/#/' | column -c 2 -t -s#
test: | unit-test
unit-test: ## Runs unit tests
@echo --- Running unit tests...
@date --rfc-3339=seconds
@go test -race -cover -failfast -tags testtools ./...
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 ./dist/
@rm -rf coverage.out
@go clean -testcache
binary: | 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: vendor ## Generates code
@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 --playground --dev --oidc=false
background-run: ## Runs in the app in the background
@echo --- Running binary in the background...
@date --rfc-3339=seconds
@go run main.go serve --dev --oidc=false --pid-file=${PID_FILE} &
kill-running: ## Kills the running binary from pid file
@echo --- Killing background binary...
@date --rfc-3339=seconds
@kill $$(cat ${PID_FILE})