-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
128 lines (101 loc) · 3.36 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
DB_URL='postgres://eutychus:[email protected]:5432/goquizbox?sslmode=disable'
MIGRATION_DIR="migrations"
.PHONY: help
help: ## Display available commands.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
compile: ## Compile the app into /tmp/quizbox
go build -o /tmp/quizbox cmd/server/main.go
compile_cli: ## Compile the cli app
go build -o /tmp/quizboxcli cmd/client/main.go
docker: ## Docker build the app into ektowett/goquizbox:latest
docker build -t ektowett/goquizbox:latest .
docker_migrate: ## Docker build the app into ektowett/goquizbox-migrate:latest
docker build -t ektowett/goquizbox-migrate:latest -f Dockerfile.migrate .
up: ## Docker Compose bring up all containers in detatched mode
docker-compose up -d
ps: ## Docker Compose check docker processes
docker-compose ps
logs: ## Docker Compose tail follow logs
docker-compose logs -f
stop: ## Docker Compose stop all containers
docker-compose stop
rm: stop ## Docker Compose stop and force remove all containers
docker-compose rm -f
GOFMT_FILES = $(shell go list -f '{{.Dir}}' ./... | grep -v '/pb')
HTML_FILES = $(shell find . -name \*.html)
GO_FILES = $(shell find . -name \*.go)
MD_FILES = $(shell find . -name \*.md)
# diff-check runs git-diff and fails if there are any changes.
diff-check:
@FINDINGS="$$(git status -s -uall)" ; \
if [ -n "$${FINDINGS}" ]; then \
echo "Changed files:\n\n" ; \
echo "$${FINDINGS}\n\n" ; \
echo "Diffs:\n\n" ; \
git diff ; \
git diff --cached ; \
exit 1 ; \
fi
.PHONY: diff-check
generate:
@go generate ./...
.PHONY: generate
# lint uses the same linter as CI and tries to report the same results running
# locally. There is a chance that CI detects linter errors that are not found
# locally, but it should be rare.
lint:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint
@golangci-lint run --config .golangci.yaml
.PHONY: lint
generate-check: generate diff-check
.PHONY: generate-check
test:
@go test \
-shuffle=on \
-count=1 \
-short \
-timeout=5m \
./...
.PHONY: test
test-acc:
@go test \
-shuffle=on \
-count=1 \
-race \
-timeout=10m \
./... \
-coverprofile=coverage.out
.PHONY: test-acc
test-coverage:
@go tool cover -func=./coverage.out
.PHONY: test-coverage
zapcheck:
@go install github.com/sethvargo/zapw/cmd/zapw
@zapw ./...
.PHONY: zapcheck
# make migration name=create_users
migration: ## Create golang goose migrations
@echo "Creating migration $(name)!"
@goose -dir $(MIGRATION_DIR) create $(name) sql
@echo "Done!"
migrate_up: ## Golang goose up migrations
@echo "Migrating up!"
@goose -dir $(MIGRATION_DIR) postgres $(DB_URL) up
@echo "Done!"
migrate_down: ## Golang goose down migrations
@echo "Migrating down!"
@goose -dir $(MIGRATION_DIR) postgres $(DB_URL) down
@echo "Done!"
migrate_status: ## Golang goose status migrations
@echo "Getting migration status!"
@goose -dir $(MIGRATION_DIR) postgres $(DB_URL) status
@echo "Done!"
migrate_reset: ## Golang goose reset migrations
@echo "Resetting $(MIGRATION_DIR)!"
@goose -dir $(MIGRATION_DIR) postgres $(DB_URL) reset
@echo "Done!"
migrate_version: ## Golang goose version migrations
@echo "Getting migration version!"
@goose -dir $(MIGRATION_DIR) postgres $(DB_URL) version
@echo "Done!"
migrate_redo: migrate_reset migrate_up ## Golang goose redo migrations - reset then up