-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
70 lines (55 loc) · 1.79 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
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=virtual_machine_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=virtual-machine-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 --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
dev-nats: ## Initializes nats
@echo --- Initializing nats
@date --rfc-3339=seconds
@.devcontainer/scripts/nats_account.sh
generate: ## 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 --dev