-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (55 loc) · 1.55 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
PROJECTNAME := $(shell basename "$(PWD)")
PKG_LIST := $(shell go list ./... | grep -v /vendor/)
DATABASE := typecoffee
## lint: Run the lint
lint:
go vet ${PKG_LIST}
## build: Build the api binary to execute
build:
go build -o ${PROJECTNAME} ./cmd/api
docker-build:
docker build -t type-coffee-api .
docker-run:
docker run --env-file=.env -p 3000:3000 type-coffee-api
## run: Run the api
run:
go run ./cmd/api
## test: Run the test of project
test:
go test ./... -race -coverpkg=./... -coverprofile=coverage.out
## coverage: Get coverage of all tests
coverage:
go tool cover -func=coverage.out
## coverage-html: Generate the report in HTML of test coverage
coverage-html:
go tool cover -html=coverage.out -o coverage.html
.PHONY: gen-go-openapi-code
gen-go-openapi-code:
mkdir -p coffee/handler
oapi-codegen --config configs/openapi/types.yml api/openapi.yaml
oapi-codegen --config configs/openapi/server.yml api/openapi.yaml
gen-go-grpc-code:
protoc --go_out=coffee --go_opt=paths=source_relative --go-grpc_out=coffee --go-grpc_opt=paths=source_relative ./api/coffee.proto
.PHONY: gen-go-sql-code
gen-go-sql-code:
sqlc generate --file configs/db/sqlc.yaml
.PHONY: pg-up
pg-up:
docker run \
--name postgres \
-p 5450:5432 \
-e POSTGRES_USER=root \
-e POSTGRES_PASSWORD=secret \
-e POSTGRES_DB=${DATABASE} \
-d --rm postgres:14
.PHONY: pg-down
pg-down:
docker stop postgres
.PHONY: help
all: help
help: Makefile
@echo
@echo " Choose a command run in "$(PROJECTNAME)":"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo