repo := foundation/admin-panel-lambdas
pkg := code.justin.tv/$(repo)
codecov := curl -s https://codecov.internal.justin.tv/bash | bash -s -
coverage-out := coverage.txt
build := build
aws-mock := mockery -note 'Code generated DO NOT EDIT' -all -output internal/mocks -dir vendor/github.com/aws/aws-sdk-go/service

.PHONY: build mocks
build: clean build-lambdas

clean:
	rm -rf $(build)
	mkdir -p $(build)
build-lambdas:
	LAMBDA="extract_cloudwatch_metrics" OUT="$(build)/extract_cloudwatch_metrics.zip" bash ./scripts/build-lambda.sh
deploy-staging:
	ENVIRONMENT="staging" LAMBDA_FN="extract_cloudwatch_metrics" LAMBDA_ZIP="$(build)/extract_cloudwatch_metrics.zip" bash ./scripts/deploy-lambda.sh
deploy-production:
	ENVIRONMENT="production" LAMBDA_FN="extract_cloudwatch_metrics" LAMBDA_ZIP="$(build)/extract_cloudwatch_metrics.zip" bash ./scripts/deploy-lambda.sh
mocks:
	$(aws-mock)/cloudwatch/cloudwatchiface

test-coverage:
	go test -coverprofile=$(coverage-out) -covermode=atomic $(pkg)/...
upload-coverage:
	$(codecov) -r $(repo) -t ${CODECOV_TOKEN} -f $(coverage-out)
