.PHONY: all precommit setup lint test integration_test build run fix jenkins
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
MAIN_DIR ?= ./...
include $(SELF_DIR)CommonMakefile.mk

GOTEST ?= .

integration_test: duplo_integration_test fanout_integration_test masonry_integration_test shine_integration_test edge_integration_test feed-settings_integration_test feedsedge_integration_test

# Separate the tests so we can run them via os.Exec() during duplo's own integration test
duplo_integration_test:
	env ENVIRONMENT=$(ENVIRONMENT) go test -race -tags=integration -run=$(GOTEST) -timeout 30s -v ./duplo/...

fanout_integration_test:
	env ENVIRONMENT=$(ENVIRONMENT) go test -race -tags=integration -run=$(GOTEST) -timeout 30s -v ./fanout/...

masonry_integration_test:
	env ENVIRONMENT=$(ENVIRONMENT) go test -race -tags=integration -run=$(GOTEST) -timeout 30s -v ./masonry/...

shine_integration_test:
	env ENVIRONMENT=$(ENVIRONMENT) go test -race -tags=integration -run=$(GOTEST) -timeout 30s -v ./shine/...

edge_integration_test:
	env ENVIRONMENT=$(ENVIRONMENT) go test -race -tags=integration -run=$(GOTEST) -timeout 30s -v ./edge/...

feedsedge_integration_test:
	env ENVIRONMENT=$(ENVIRONMENT) go test -race -tags=integration -run=$(GOTEST) -timeout 30s -v ./feedsedge/...

feed-settings_integration_test:
	env ENVIRONMENT=$(ENVIRONMENT) go test -race -tags=integration -run=$(GOTEST) -timeout 30s -v ./feed-settings/...

restore_dep:
	dep ensure -vendor-only

jenkins: setup restore_dep lint test build
	go env
	go version
	env
	mkdir /build/output
	touch /build/output/.keep
