pb_path = server/grpc/pb
env=devten
name=urus-shipment-service
option=-f

gen-proto:
	protoc \
		--go_out=${pb_path} --go_opt=paths=source_relative \
		--go-grpc_out=${pb_path} --go-grpc_opt=paths=source_relative \
		--proto_path=${pb_path} ${pb_path}/*.proto

# One time tooling setup.
dev-setup:
	go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
	go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1

run:
	go run cmd/app/main.go run

swagger:
	swag init --parseDependency --parseInternal --parseDepth 1 -g cmd/app/main.go

migrate-up:
	go run ./cmd/app migrate -d up

migrate-down:
	go run ./cmd/app migrate -d down

devlog:
	kubectl logs deployment/urus-shipment-service -n devten -f

mock-domain:
	cd ./domain; mockery --all --keeptree --output=mock

test-domain:
	go test ./domain/... -v

test:
	go test ./domain/... -coverprofile cover.out.tmp
	go tool cover -func cover.out.tmp

coverage:
	go test ./domain/... -coverprofile cover.out.tmp
	go tool cover -func cover.out.tmp | grep total | awk '{print substr($3, 1, length($3)-1) > "shipment.coverage.txt"}'
	rm -rf ./cover.out.tmp

coverage-html:
	go test ./domain/... -coverprofile cover.out.tmp
	go tool cover -html cover.out.tmp -o cover.out.html