-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (58 loc) · 1.91 KB
/
Copy pathMakefile
File metadata and controls
73 lines (58 loc) · 1.91 KB
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
# Include variables from the .envrc file
include .envrc
# ======================================================================== #
# HELPERS
# ======================================================================== #
## help: print this help message.
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
.PHONY: confirm
confirm:
@echo -n 'Are you sure? [Y/N] ' && read ans && [ $${ans:-N} = y ]
# ======================================================================== #
# CODE QUALITY CONTROL
# ======================================================================== #
## audit: perform all code quality checks and module dependency resolution & verification.
.PHONY: audit
audit: format
@echo '.....Tidying, verifying and resolving module dependencies.....'
go mod tidy
go mod verify
.PHONY: fmt
fmt:
@echo '.....Formatting go code.....'
go fmt ./...
.PHONY:lint
lint: fmt
@echo '.....Linting go code.....'
golint ./...
.PHONY: vet
vet: lint
@echo '.....Vetting go code.....'
go vet ./...
## format: format & lint all go files.
.PHONY: format
format: vet
.PHONY: vendor
vendor: audit
@echo '.....Vendoring app dependencies.....'
go mod vendor
# ======================================================================== #
# DEVELOPMENT
# ======================================================================== #
## start: run the ./cmd/api/ application.
.PHONY: start
start:
@go run ./cmd/api/ -db-dsn=${SUNRISE_API_POSTGRES_DSN}
## db/migrations/new name=$1: create a new database migration.
.PHONY: db/migrations/new
db/migrations/new:
@echo '.....Creating migration files for ${name}.....'
migrate create -seq -ext=.sql -dir=./migrations ${name}
## db/migrations/up: apply all up database migrations.
.PHONY: db/migrations/up
db/migrations/up: confirm
@echo '.....Running up migrations.....'
migrate -path ./migrations -database ${SUNRISE_API_POSTGRES_DSN} up