This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
66 lines (53 loc) · 1.8 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
PROJECT_NAME=$(shell basename "$(PWD)")
SCRIPT_AUTHOR=Andrey Kapitonov <[email protected]>
SCRIPT_VERSION=0.0.5.dev
SERVICES=\
common \
storage
all: tests
common_proto:
protoc -I . \
--go_out=. \
--go_opt=paths=source_relative \
--go-grpc_out=. \
--go-grpc_opt=paths=source_relative \
./src/protobuf/common/*.proto;
$(SERVICES):
protoc -I ./src/protobuf/$@/ -I . \
--go_out=./src/protobuf/$@/ \
--go_opt=paths=source_relative \
--go-grpc_out=./src/protobuf/$@/ \
--go-grpc_opt=paths=source_relative \
default: common_proto $(SERVICES)
# Download and install golangci-linter
linter:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.40.1
mv ./bin/golangci-lint /bin
rm -rf ./bin
deploy: build-migration-tool migrate-up
tests:
go test ./... -v
build-migration-tool:
git clone https://github.com/rubenv/sql-migrate
cd ./sql-migrate/sql-migrate && go build && cd ../..
mv ./sql-migrate/sql-migrate/sql-migrate ./cmd
rm -rf ./sql-migrate
migrate-up:
./src/cmd/sql-migrate up -config=./cmd/dbconfig.yml
migrate-down:
./src/cmd/sql-migrate down -config=./cmd/dbconfig.yml
migrate-status:
./src/cmd/sql-migrate status -config=./cmd/dbconfig.yml
migrate-new:
./src/cmd/sql-migrate new $(name) -config=./cmd/dbconfig.yml
help:
@echo -e "Usage: make [target] ...\n"
@echo -e "build-migration-tool : Download & create migration tool"
@echo -e "migrate-up : Apply migrations"
@echo -e "migrate-down : Down migrations"
@echo -e "migrate-status : Status of migrations"
@echo -e "migrate-new : Create new migration by name={name_here}"
@echo -e '\nProject name : '$(PROJECT_NAME)
@echo -e "Written by $(SCRIPT_AUTHOR), version $(SCRIPT_VERSION)"
@echo -e "Please report any bug or error to the author."