-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
145 lines (120 loc) · 6.88 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
APP_NAME=mochi-api
DEFAULT_PORT=8200
POSTGRES_TEST_CONTAINER?=mochi_local_test
.PHONY: setup init build dev test migrate-up migrate-down
setup:
go install github.com/rubenv/sql-migrate/...@latest
go install github.com/golang/mock/[email protected]
go install github.com/vektra/mockery/v2@latest
go install github.com/swaggo/swag/cmd/[email protected]
go install github.com/cosmtrek/air@latest
cp .env.sample .env
make init
init:
go install github.com/rubenv/sql-migrate/...@latest
make remove-infras
docker-compose up -d
@echo "Waiting for database connection..."
@while ! docker exec mochi-postgres pg_isready > /dev/null; do \
sleep 1; \
done
make migrate-up
init-test:
go install github.com/rubenv/sql-migrate/...@latest
docker-compose up -d postgres postgres_test redis
@echo "Waiting for database connection..."
@while ! docker exec $(POSTGRES_TEST_CONTAINER) pg_isready > /dev/null; do \
sleep 1; \
done
make migrate-test
remove-infras:
docker-compose down --remove-orphans
build:
env GOOS=darwin GOARCH=amd64 go build -o bin ./...
dev:
go run ./cmd/server/main.go
air:
air -c .air.toml
test:
make migrate-test
@PROJECT_PATH=$(shell pwd) go test -cover ./...
migrate-test:
sql-migrate up -env=test
migrate-new:
sql-migrate new -env=local ${name}
migrate-up:
sql-migrate up -env=local
migrate-down:
sql-migrate down -env=local
docker-build:
docker build \
--build-arg DEFAULT_PORT="${DEFAULT_PORT}" \
-t ${APP_NAME}:latest .
seed-db:
@docker exec -t mochi-postgres sh -c "mkdir -p /seed"
@docker exec -t mochi-postgres sh -c "rm -rf /seed/*"
@docker cp migrations/seed mochi-postgres:/
@docker exec -t mochi-postgres sh -c "PGPASSWORD=postgres psql -U postgres -d mochi_local -f /seed/seed.sql"
gen-mock:
@mockgen -source=./pkg/repo/guild_user_xp/store.go -destination=./pkg/repo/guild_user_xp/mocks/store.go
@mockgen -source=./pkg/repo/guild_user_activity_log/store.go -destination=./pkg/repo/guild_user_activity_log/mocks/store.go
@mockgen -source=./pkg/repo/discord_guilds/store.go -destination=./pkg/repo/discord_guilds/mocks/store.go
@mockgen -source=./pkg/repo/config_xp_level/store.go -destination=./pkg/repo/config_xp_level/mocks/store.go
@mockgen -source=./pkg/repo/token/store.go -destination=./pkg/repo/token/mocks/store.go
@mockgen -source=./pkg/repo/guild_config_token/store.go -destination=./pkg/repo/guild_config_token/mocks/store.go
@mockgen -source=./pkg/repo/chain/store.go -destination=./pkg/repo/chain/mocks/store.go
@mockgen -source=./pkg/service/coingecko/service.go -destination=./pkg/service/coingecko/mocks/service.go
@mockgen -source=./pkg/service/covalent/service.go -destination=./pkg/service/covalent/mocks/service.go
@mockgen -source=./pkg/repo/guild_config_sales_tracker/store.go -destination=./pkg/repo/guild_config_sales_tracker/mocks/store.go
@mockgen -source=./pkg/service/indexer/service.go -destination=./pkg/service/indexer/mocks/service.go
@mockgen -source=./pkg/service/marketplace/service.go -destination=./pkg/service/marketplace/mocks/service.go
@mockgen -source=./pkg/service/abi/service.go -destination=./pkg/service/abi/mocks/service.go
@mockgen -source=./pkg/service/discord/service.go -destination=./pkg/service/discord/mocks/service.go
@mockgen -source=./pkg/service/processor/service.go -destination=./pkg/service/processor/mocks/service.go
@mockgen -source=./pkg/service/skymavis/service.go -destination=./pkg/service/skymavis/mocks/service.go
@mockgen -source=./pkg/service/ronin/service.go -destination=./pkg/service/ronin/mocks/service.go
@mockgen -source=./pkg/repo/nft_collection/store.go -destination=./pkg/repo/nft_collection/mocks/store.go
@mockgen -source=./pkg/repo/guild_config_level_role/store.go -destination=./pkg/repo/guild_config_level_role/mocks/store.go
@mockgen -source=./pkg/repo/guild_config_wallet_verification_message/store.go -destination=./pkg/repo/guild_config_wallet_verification_message/mocks/store.go
@mockgen -source=./pkg/repo/coingecko_supported_tokens/store.go -destination=./pkg/repo/coingecko_supported_tokens/mocks/store.go
@mockgen -source=./pkg/repo/user_token_watchlist_item/store.go -destination=./pkg/repo/user_token_watchlist_item/mocks/store.go
@mockgen -source=./pkg/repo/guild_config_gm_gn/store.go -destination=./pkg/repo/guild_config_gm_gn/mocks/store.go
@mockgen -source=./pkg/repo/discord_user_gm_streak/store.go -destination=./pkg/repo/discord_user_gm_streak/mocks/store.go
@mockgen -source=./pkg/repo/guild_config_welcome_channel/store.go -destination=./pkg/repo/guild_config_welcome_channel/mocks/store.go
@mockgen -source=./pkg/repo/message_repost_history/store.go -destination=./pkg/repo/message_repost_history/mocks/store.go
@mockgen -source=./pkg/repo/guild_config_default_roles/store.go -destination=./pkg/repo/guild_config_default_roles/mocks/store.go
@mockgen -source=./pkg/repo/guild_config_reaction_roles/store.go -destination=./pkg/repo/guild_config_reaction_roles/mocks/store.go
@mockgen -source=./pkg/repo/quest/store.go -destination=./pkg/repo/quest/mocks/store.go
@mockgen -source=./pkg/repo/quest_reward_type/store.go -destination=./pkg/repo/quest_reward_type/mocks/store.go
@mockgen -source=./pkg/repo/quest_user_log/store.go -destination=./pkg/repo/quest_user_log/mocks/store.go
@mockgen -source=./pkg/repo/quest_user_list/store.go -destination=./pkg/repo/quest_user_list/mocks/store.go
@mockgen -source=./pkg/repo/quest_pass/store.go -destination=./pkg/repo/quest_pass/mocks/store.go
@mockgen -source=./pkg/repo/quest_user_pass/store.go -destination=./pkg/repo/quest_user_pass/mocks/store.go
@mockgen -source=./pkg/repo/quest_reward/store.go -destination=./pkg/repo/quest_reward/mocks/store.go
@mockgen -source=./pkg/repo/quest_user_reward/store.go -destination=./pkg/repo/quest_user_reward/mocks/store.go
@mockgen -source=./pkg/repo/offchain_tip_bot_chain/store.go -destination=./pkg/repo/offchain_tip_bot_chain/mocks/store.go
@mockgen -source=./pkg/repo/offchain_tip_bot_tokens/store.go -destination=./pkg/repo/offchain_tip_bot_tokens/mocks/store.go
setup-githook:
@echo Setting up softlink pre-commit hooks
@git config core.hooksPath .githooks/
@chmod +x .githooks/*
@echo - done -
gen-swagger:
swag init --parseDependency --parseInternal -g ./cmd/server/main.go
pprof:
rm -f torch.svg && docker run uber/go-torch -u http://host.docker.internal:8200/debug/pprof -p -t=30 > torch.svg
RELEASE_BRANCH=master
BETA_BRANCH=develop
DEVELOP_BRANCH=develop
.PHONY: release
release: sync-release
git checkout $(BETA_BRANCH) && git pull origin $(BETA_BRANCH) && \
git checkout $(RELEASE_BRANCH) && git pull origin $(RELEASE_BRANCH) && \
git merge $(BETA_BRANCH) --no-edit --no-ff && \
git push origin $(RELEASE_BRANCH) && \
git checkout $(DEVELOP_BRANCH) && git push origin $(DEVELOP_BRANCH)
.PHONY: sync-release
sync-release:
git checkout $(RELEASE_BRANCH) && git pull origin $(RELEASE_BRANCH) && \
git checkout $(BETA_BRANCH) && git pull origin $(BETA_BRANCH) && \
git merge $(RELEASE_BRANCH) --no-edit --no-ff