-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (46 loc) · 1.63 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
## ----------------------
## Available make targets
## ----------------------
##
default: help
help: ## Display this message
@grep -E '(^[a-zA-Z0-9_\-\.]+:.*?##.*$$)|(^##)' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
##
## ----------------------
## Builds
## ----------------------
##
artifact: ## Compile app from sources (linux)
@CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o cop-orm ./cmd/cop-orm
artifact.osx: ## Compile app from sources (osx)
@CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o cop-orm ./cmd/cop-orm
##
## ----------------------
## Q.A
## ----------------------
##
qa: lint test ## Run all Q.A
lint.install: ## Install Go linter
go install github.com/golangci/golangci-lint/cmd/golangci-lint
lint: ## Lint source code
golangci-lint run -v
lint.fix: ## Lint and fix source code
golangci-lint run --fix -v
test: ## Run unit tests (go test)
@echo "### Running unit tests ..."
go test -v ./... -coverprofile coverage.out
##
## ----------------------
## Development
## ----------------------
##
install: ## Install required goland dependencies
go mod download
start: ## Start project
go run ./cmd/cop-orm
init-db: create-postgres create-cop-orm-db ## Initialize the database
@sleep 5
create-postgres: ## Create a PostgreSQL instance using Docker
docker run --name postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
create-cop-orm-db: ## Create a cop-orm database
docker exec -it postgres createdb -U postgres cop-orm