all: lint

.PHONY: setup lint mocks test glide

lint:
	golint code.justin.tv/chat/friendship/...

GO_MOCK=mockery -note @generated -inpkg -dir $(GOPATH)/src/code.justin.tv/chat/friendship
mocks:
	mockery -inpkg -dir $(GOPATH)/src/code.justin.tv/chat/friendship/client -name Client

	$(GO_MOCK)/clients -name DynamoDBInterface
	$(GO_MOCK)/clients -name IMStoreInterface
	$(GO_MOCK)/clients -name PartnershipsInterface
	$(GO_MOCK)/clients -name RailsInterface
	$(GO_MOCK)/clients -name SNSInterface
	$(GO_MOCK)/clients -name TMIInterface
	$(GO_MOCK)/clients -name UsersInterface
	$(GO_MOCK)/clients -name ZumaInterface

test:
	errcheck -blank -ignoretests ./app/...
	go test -race code.justin.tv/chat/friendship/...

glide:
	glide up --strip-vendor
	glide-vc --only-code --use-lock-file --no-tests --no-legal-files --keep '**/*.json'

setup:
	brew install protobuf
	gem install foreman
	go get -u github.com/kisielk/errcheck
	go get -u github.com/vektra/mockery/...
	go get -u github.com/golang/protobuf/protoc-gen-go
	go get -u code.justin.tv/common/twirp/protoc-gen-twirp

proto:
	protoc --proto_path=$(GOPATH)/src:. --twirp_out=. --go_out=. ./rpc/friends/service.proto
	sed -i '' 's/"golang.org\/x\/net\/context"/"context"/' rpc/friends/service.twirp.go
