forked from Shyp/rickover
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
102 lines (74 loc) · 2.47 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
.PHONY: test race-test
SHELL = /bin/bash -o pipefail
ifdef DATABASE_URL
DATABASE_URL := $(DATABASE_URL)
else
DATABASE_URL := 'postgres://rickover@localhost:5432/rickover?sslmode=disable&timezone=UTC'
endif
export GO111MODULE=on
BENCHSTAT := $(GOPATH)/bin/benchstat
BUMP_VERSION := $(GOPATH)/bin/bump_version
GODOCDOC := $(GOPATH)/bin/godocdoc
GOOSE := $(GOPATH)/bin/goose
TRUNCATE_TABLES := $(GOPATH)/bin/rickover-truncate-tables
# Just run it every time, we could get fancy with find() tricks, but eh.
$(TRUNCATE_TABLES):
go install ./test/rickover-truncate-tables
staticcheck:
go install honnef.co/go/tools/cmd/staticcheck@latest
goose:
go install github.com/kevinburke/goose/cmd/goose@latest
build:
go build ./...
test-install:
-createuser rickover --host localhost --superuser --createrole --createdb --inherit -U postgres
-createdb rickover --host localhost --owner=rickover -U postgres
-createdb rickover_test --host localhost --owner=rickover -U postgres
-psql --command='CREATE EXTENSION "uuid-ossp"' rickover_test
migrate-ci:
# PG 14 is installed by default on the ubuntu-latest image
sudo -u postgres /usr/bin/pg_ctlcluster --skip-systemctl-redirect 14 main start
cp -f ./bin/migrate /tmp
sudo -u postgres psql -f /tmp/migrate
psql --command='CREATE EXTENSION "uuid-ossp"' $$(cat envs/github/DATABASE_URL)
goose --env=github up
lint:
go vet ./...
staticcheck ./...
docs:
go install github.com/kevinburke/godocdoc
godocdoc
testonly:
envdir envs/test go test -p=1 -timeout 10s ./...
race-testonly:
envdir envs/test go test -p=1 -race -timeout 10s ./...
truncate-test: $(TRUNCATE_TABLES)
envdir envs/test $(TRUNCATE_TABLES)
race-test: race-testonly truncate-test
test: testonly truncate-test
serve:
DATABASE_URL=$(DATABASE_URL) go run commands/server/main.go
dequeue:
@DATABASE_URL=$(DATABASE_URL) go run commands/dequeuer/main.go
$(BUMP_VERSION):
go get -u github.com/kevinburke/bump_version
release: race-test | $(BUMP_VERSION)
$(BUMP_VERSION) minor config/config.go
git push origin master
git push origin master --tags
GOOSE:
go get -u github.com/kevinburke/goose/cmd/goose
migrate: | $(GOOSE)
$(GOOSE) --env=development up
$(GOOSE) --env=test up
$(BENCHSTAT):
go get -u golang.org/x/perf/cmd/benchstat
benchmark-ci:
go run ./test/cmd/populate-queued-jobs/main.go
go test -bench=. -run='^$$' -v ./...
bench: | $(BENCHSTAT)
go test -p=1 -benchtime=2s -bench=. -run='^$$' 2>&1 | $(BENCHSTAT) /dev/stdin
sql:
sqlc generate
cloc:
cloc --exclude-dir=vendor .