-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
105 lines (88 loc) · 4.66 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
include .env
LOCAL_BIN:=$(CURDIR)/bin
LOCAL_MIGRATION_DIR=$(MIGRATION_DIR)
LOCAL_MIGRATION_DSN="host=ep-steep-water-a2fls7tp-pooler.eu-central-1.aws.neon.tech port=$(PG_PORT) dbname=$(PG_DATABASE_NAME) user=$(PG_USER) password=$(PG_PASSWORD) sslmode=require"
install-golangci-lint:
GOBIN=$(LOCAL_BIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
lint:
bin/golangci-lint run ./... --config .golangci.pipeline.yaml
install-deps:
GOBIN=$(LOCAL_BIN) go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
GOBIN=$(LOCAL_BIN) go install -mod=mod google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
GOBIN=$(LOCAL_BIN) go install github.com/pressly/goose/v3/cmd/goose@v3.14.0
GOBIN=$(LOCAL_BIN) go install github.com/envoyproxy/protoc-gen-validate@v0.10.1
GOBIN=$(LOCAL_BIN) go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.15.2
GOBIN=$(LOCAL_BIN) go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.15.2
GOBIN=$(LOCAL_BIN) go install github.com/rakyll/statik@v0.1.7
get-deps:
go get -u google.golang.org/protobuf/cmd/protoc-gen-go
go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc
generate:
mkdir -p pkg/swagger
make generate-user-api
make generate-auth-api
make generate-access-api
$(LOCAL_BIN)/statik -src=pkg/swagger/ -include='*.css,*.html,*.js,*.json,*.png'
generate-user-api:
mkdir -p pkg/user_v1
protoc --proto_path api/user_v1 --proto_path vendor.protogen \
--go_out=pkg/user_v1 --go_opt=paths=source_relative \
--plugin=protoc-gen-go=$(LOCAL_BIN)/protoc-gen-go \
--go-grpc_out=pkg/user_v1 --go-grpc_opt=paths=source_relative \
--plugin=protoc-gen-go-grpc=$(LOCAL_BIN)/protoc-gen-go-grpc \
--validate_out lang=go:pkg/user_v1 --validate_opt=paths=source_relative \
--plugin=protoc-gen-validate=$(LOCAL_BIN)/protoc-gen-validate \
--grpc-gateway_out=pkg/user_v1 --grpc-gateway_opt=paths=source_relative \
--plugin=protoc-gen-grpc-gateway=$(LOCAL_BIN)/protoc-gen-grpc-gateway \
--openapiv2_out=allow_merge=true,merge_file_name=api:pkg/swagger \
--plugin=protoc-gen-openapiv2=$(LOCAL_BIN)/protoc-gen-openapiv2 \
api/user_v1/user.proto
generate-auth-api:
mkdir -p pkg/auth_v1
protoc --proto_path api/auth_v1 --proto_path vendor.protogen \
--go_out=pkg/auth_v1 --go_opt=paths=source_relative \
--plugin=protoc-gen-go=$(LOCAL_BIN)/protoc-gen-go \
--go-grpc_out=pkg/auth_v1 --go-grpc_opt=paths=source_relative \
--plugin=protoc-gen-go-grpc=$(LOCAL_BIN)/protoc-gen-go-grpc \
--validate_out lang=go:pkg/auth_v1 --validate_opt=paths=source_relative \
--plugin=protoc-gen-validate=$(LOCAL_BIN)/protoc-gen-validate \
--grpc-gateway_out=pkg/auth_v1 --grpc-gateway_opt=paths=source_relative \
--plugin=protoc-gen-grpc-gateway=$(LOCAL_BIN)/protoc-gen-grpc-gateway \
--openapiv2_out=allow_merge=true,merge_file_name=api_auth:pkg/swagger \
--plugin=protoc-gen-openapiv2=$(LOCAL_BIN)/protoc-gen-openapiv2 \
api/auth_v1/auth.proto
generate-access-api:
mkdir -p pkg/access_v1
protoc --proto_path api/access_v1 \
--go_out=pkg/access_v1 --go_opt=paths=source_relative \
--plugin=protoc-gen-go=$(LOCAL_BIN)/protoc-gen-go \
--go-grpc_out=pkg/access_v1 --go-grpc_opt=paths=source_relative \
--plugin=protoc-gen-go-grpc=$(LOCAL_BIN)/protoc-gen-go-grpc \
api/access_v1/access.proto
local-migration-status:
$(LOCAL_BIN)/goose -dir ${LOCAL_MIGRATION_DIR} postgres ${LOCAL_MIGRATION_DSN} status -v
create-migration:
$(LOCAL_BIN)/goose -dir ${LOCAL_MIGRATION_DIR} create users_table sql
local-migration-up:
$(LOCAL_BIN)/goose -dir ${LOCAL_MIGRATION_DIR} postgres ${LOCAL_MIGRATION_DSN} up -v
local-migration-down:
$(LOCAL_BIN)/goose -dir ${LOCAL_MIGRATION_DIR} postgres ${LOCAL_MIGRATION_DSN} down -v
vendor-proto:
@if [ ! -d vendor.protogen/validate ]; then \
mkdir -p vendor.protogen/validate &&\
git clone https://github.com/envoyproxy/protoc-gen-validate vendor.protogen/protoc-gen-validate &&\
mv vendor.protogen/protoc-gen-validate/validate/*.proto vendor.protogen/validate &&\
rm -rf vendor.protogen/protoc-gen-validate ;\
fi
@if [ ! -d vendor.protogen/google ]; then \
git clone https://github.com/googleapis/googleapis vendor.protogen/googleapis &&\
mkdir -p vendor.protogen/google/ &&\
mv vendor.protogen/googleapis/google/api vendor.protogen/google &&\
rm -rf vendor.protogen/googleapis ;\
fi
@if [ ! -d vendor.protogen/protoc-gen-openapiv2 ]; then \
mkdir -p vendor.protogen/protoc-gen-openapiv2/options &&\
git clone https://github.com/grpc-ecosystem/grpc-gateway vendor.protogen/openapiv2 &&\
mv vendor.protogen/openapiv2/protoc-gen-openapiv2/options/*.proto vendor.protogen/protoc-gen-openapiv2/options &&\
rm -rf vendor.protogen/openapiv2 ;\
fi