
# Docker is used on the CI server (Jenkins) to run tasks from a container.
DOCKER_IMAGE=lib-lifecycle
DOCKER_WORKDIR=/build/go/src/code.justin.tv/devhub/lib-lifecycle/src
define docker_run
	@docker run -v $(PWD):$(DOCKER_WORKDIR) -w $(DOCKER_WORKDIR) --rm $(DOCKER_IMAGE) /bin/bash -c "echo \">> $(1): running from Docker workdir: $(DOCKER_WORKDIR)\" && $(1)"
endef

dep:
	# Generate vendor files from Gopkg and code imports.
	# Use after adding/updating imports in Golang. (install: brew install dep)
	dep ensure

docker-image:
	docker image build -t $(DOCKER_IMAGE) .

lint:
	# Using default linters (golangci-lint help linters) (brew install golangci/tap/golangci-lint)
	golangci-lint run

lint-docker: docker-image
	$(call docker_run,make lint)

test:
	go test -race ./...

test-docker: docker-image
	$(call docker_run,make test)
