repo := foundation/history-service
pkg := code.justin.tv/$(repo)
codecov := curl -s https://codecov.internal.justin.tv/bash | bash -s -
coverage-out := coverage.txt
mock := retool do mockery -note 'Code generated DO NOT EDIT' -all

PAGERDUTY_URL = "https://events.pagerduty.com/generic/2010-04-15/create_event.json"

.PHONY: mocks

test-coverage:
	go test -coverprofile=$(coverage-out) -covermode=atomic $(pkg)/...

upload-coverage:
	$(codecov) -r $(repo) -t ${CODECOV_TOKEN} -f $(coverage-out)

twirp-gen:
	retool do protoc --twirp_out=. --go_out=. ./rpc/history/service.proto

mocks:
	$(mock) -outpkg awsmocks -output ./internal/awsmocks -dir ./vendor/github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface
	$(mock) -outpkg awsmocks -output ./internal/awsmocks -dir ./vendor/github.com/aws/aws-sdk-go/service/s3/s3iface
	$(mock) -outpkg awsmocks -output ./internal/awsmocks -dir ./vendor/github.com/aws/aws-sdk-go/service/sqs/sqsiface
	$(mock) -outpkg awsmocks -output ./internal/awsmocks -dir ./vendor/github.com/aws/aws-sdk-go/service/s3/s3manager/s3manageriface
	$(mock) -outpkg awsmocks -output ./internal/awsmocks -dir ./vendor/github.com/aws/aws-sdk-go/service/ecs/ecsiface
	$(mock) -outpkg gdprmocks -output ./internal/gdpr/gdprmocks -dir ./internal/gdpr

notify-failure:
	./bin/alarm $(PAGERDUTY_URL)
