-
Notifications
You must be signed in to change notification settings - Fork 61
/
Makefile
57 lines (48 loc) · 1.57 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
# Public variables
DESTDIR ?=
PREFIX ?= /usr/local
OUTPUT_DIR ?= out
DST ?=
# Private variables
obj = weron
all: $(addprefix build/,$(obj))
# Build
build: $(addprefix build/,$(obj))
$(addprefix build/,$(obj)):
ifdef DST
go build -o $(DST) ./cmd/$(subst build/,,$@)
else
go build -o $(OUTPUT_DIR)/$(subst build/,,$@) ./cmd/$(subst build/,,$@)
endif
# Install
install: $(addprefix install/,$(obj))
$(addprefix install/,$(obj)):
install -D -m 0755 $(OUTPUT_DIR)/$(subst install/,,$@) $(DESTDIR)$(PREFIX)/bin/$(subst install/,,$@)
# Uninstall
uninstall: $(addprefix uninstall/,$(obj))
$(addprefix uninstall/,$(obj)):
rm $(DESTDIR)$(PREFIX)/bin/$(subst uninstall/,,$@)
# Run
$(addprefix run/,$(obj)):
$(subst run/,,$@) $(ARGS)
# Test
test:
go test -timeout 3600s -parallel $(shell nproc) ./...
# Benchmark
benchmark:
go test -timeout 3600s -bench=./... ./...
# Clean
clean:
rm -rf out internal/db
docker rm -f weron-postgres weron-redis
# Dependencies
depend:
docker run -d --name weron-postgres -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -e POSTGRES_DB=weron_communities postgres
docker run -d --name weron-redis -p 6379:6379 valkey/valkey
docker exec weron-postgres bash -c 'until pg_isready; do sleep 1; done'
go install github.com/rubenv/sql-migrate/sql-migrate@latest
go install github.com/volatiletech/sqlboiler/v4@latest
go install github.com/jteeuwen/go-bindata/go-bindata@latest
go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest
sql-migrate up -env="psql" -config configs/sql-migrate/communities.yaml
go generate ./internal/persisters/psql/...