novendor = $(shell go list ./... | grep -v vendor/)
unittestpackages = $(shell go list ./... | grep -v vendor/)

# Run the local go server with docker
docker:
	# Build with docker
	docker build -t daggerfall .
	# Run docker
	docker run \
	--env AWS_ACCESS_KEY_ID=$(shell aws configure get aws_access_key_id --profile twitch-daggerfall-dev) \
	--env AWS_SECRET_ACCESS_KEY=$(shell aws configure get aws_secret_access_key --profile twitch-daggerfall-dev) \
	--env AWS_DEFAULT_REGION=us-west-2 \
	--env ENVIRONMENT=local \
	--env SERVICE_NAME=daggerfall-dev \
	-p 8080:8080  -it --rm --name daggerfall daggerfall

all: release

# Runs all tasks that need to be done as part of a release.
release: fmt lint quiet-test install

# Run all static checks
lint:
	go vet -composites=false $(novendor)
	# TODO: Uncomment
	# errcheck -blank $(novendor)
	golint $(novendor)

# Run auto-formatting
fmt:
	go fmt $(novendor)

# Build the executable
install:
	go install code.justin.tv/extensions/daggerfall/cmd/...

# Run unit tests
test:
	go test -race $(unittestpackages)

