#MakeFile
PROTO_SRC  := ../api/workflow/workflow_service.proto
PROTO_DIR  := ../api/workflow
STUB_DIR   := fluid_workflow_engine_sdk/_proto

gen-stubs:
	python -m grpc_tools.protoc \
		--proto_path=$(PROTO_DIR) \
		--python_out=$(STUB_DIR) \
		--grpc_python_out=$(STUB_DIR) \
		workflow_service.proto
	python -c "\
	import re, pathlib; \
	f = pathlib.Path('$(STUB_DIR)/workflow_service_pb2_grpc.py'); \
	f.write_text(re.sub(r'^import workflow_service_pb2', \
	  'from fluid_workflow_engine_sdk._proto import workflow_service_pb2', \
	  f.read_text(), flags=re.MULTILINE))"

# Unit + offline (FakeEngine) integration tests; e2e excluded via pyproject addopts.
test:
	pytest tests/ -v

# Just the offline FakeEngine integration tier.
test-integration:
	pytest tests/integration -v -m integration

# Real engine + MongoDB. Prereqs: `make build` at the repo root, `make e2e-up`.
# To target an already-running engine set FLUID_E2E_ENGINE_ADDR / FLUID_E2E_HTTP_BASE.
test-e2e:
	FLUID_E2E=1 pytest tests/e2e -v -m e2e

e2e-up:
	docker compose -f tests/e2e/docker-compose.yml up -d --wait

e2e-down:
	docker compose -f tests/e2e/docker-compose.yml down -v

.PHONY: gen-stubs test test-integration test-e2e e2e-up e2e-down
