SHELL := /bin/bash

PROXY_HOST = discovery-production.prod.us-west2.twitch.tv

.PHONY: envcheck test run upgrade

envcheck:
	# Verify go version and network connection
	@ expr $$(go version | cut -f3 -d " " | cut -c3-) \>= 1.7 >/dev/null || \
		(echo "$$(tput bold)[ERROR] Please use go1.7 or greater $$(tput sgr0)" && false)
	@ ping -c 1 $(PROXY_HOST) >/dev/null || \
		(echo "$$(tput bold)[ERROR] Please ensure you're connected to JTV-SFO-WPA2 $$(tput sgr0)" && false)

test:
	# Unit tests with coverage analysis
	go test -cover ./...

run:
	# Run discovery server
	foreman start discovery

upgrade: envcheck
	# Upgrade glide dependencies and remove tests
	glide update --strip-vendor
	glide-vc --use-lock-file --only-code --no-tests
