-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (34 loc) · 1.1 KB
/
Makefile
File metadata and controls
46 lines (34 loc) · 1.1 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
SHELL = bash -o pipefail
TEST_FLAGS ?= -p 1 -v -count=1 -timeout 120s
PG_HOST ?= 127.0.0.1
PG_PASSWORD ?= postgres
PG_USER ?= postgres
PG_DATABASE ?= pgqueue_test
all:
@echo "make <cmd>"
@echo ""
@echo "commands:"
@echo " build - Build"
@echo " test - Run tests (requires Postgres)"
@echo " test-reset - Reset DB and run tests"
@echo " lint - Run go vet"
@echo " db-create - Create test database"
@echo " db-drop - Drop test database"
@echo " clean - Clear caches"
build:
go build ./...
lint:
go vet ./...
test:
GOGC=off go test $(TEST_FLAGS) ./...
test-reset: db-reset test
test-clean:
go clean -testcache
clean:
go clean -cache -testcache
db-reset: db-drop db-create
db-create:
@PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -U $(PG_USER) -c "CREATE DATABASE $(PG_DATABASE)" 2>/dev/null || true
db-drop:
@PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -U $(PG_USER) -c "DROP DATABASE IF EXISTS $(PG_DATABASE)" 2>/dev/null || true
.PHONY: all build lint test test-reset test-clean clean db-reset db-create db-drop