GO ?= go

.PHONY: build run test test-integration lint seed smoke backup restore

build:
	$(GO) build ./...
	cd services/atomizer && $(GO) build ./...

run:
	$(GO) run ./cmd/app

test:
	$(GO) test ./...

# Requires Mongo reachable on 127.0.0.1:27017 (or MONGO_TEST_URI):
#   docker compose -f docker-compose.yml -f docker-compose.test.yml up -d mongo
test-integration:
	$(GO) test -tags=integration ./...

# Requires the mock services running:
#   docker compose --profile mocks up -d --build atomizer-mock work-performer
test-contract:
	ATOMIZER_TOKEN=$$(grep '^ATOMIZER_TOKEN=' .env | cut -d= -f2-) \
	WORK_PERFORMER_TOKEN=$$(grep '^WORK_PERFORMER_TOKEN=' .env | cut -d= -f2-) \
	$(GO) test -tags=contract -count=1 -timeout=8m ./internal/contract/

lint:
	@unformatted=$$(gofmt -l .); if [ -n "$$unformatted" ]; then \
		echo "gofmt needed on:"; echo "$$unformatted"; exit 1; fi
	$(GO) vet ./...

seed:
	@echo "seed script lands in phase 12 (scripts/seed.go)"; exit 1

smoke:
	./scripts/smoke.sh

backup:
	@echo "backup target lands in phase 12"; exit 1

restore:
	@echo "restore target lands in phase 12"; exit 1
