11# Bazel wrapper
22BAZEL = ./tool/bazel
33
4- # Docker Compose wrapper
4+ # Docker Compose wrapper (for local dev only)
55COMPOSE = docker-compose
66COMPOSE_FILE = example/server/docker-compose.yml
7- GATEWAY_COMPOSE_FILE = example/server/gateway/docker-compose.yml
8- ORCHESTRATOR_COMPOSE_FILE = example/server/orchestrator/docker-compose.yml
97
108# Fixed project name for local manual testing (tests use unique random names)
119LOCAL_PROJECT = submitqueue
1210
1311# Set REPO_ROOT for docker-compose
1412export REPO_ROOT := $(shell pwd)
1513
16- .PHONY : build build-all-linux build-gateway-linux build-orchestrator-linux clean clean-proto deps e2e-test gazelle integration-test integration-test-extensions integration-test-gateway integration-test-orchestrator local-clean local-gateway-start local-gateway-stop local-init-schemas local-logs local-orchestrator-start local-orchestrator-stop local-ps local-restart local-start local-stop proto query-deps query-targets run-client-gateway run-client-orchestrator run-client-speculator test test-no-cache help
14+ # Detect host architecture for cross-compiling Linux binaries
15+ ARCH := $(shell uname -m)
16+ ifeq ($(ARCH ) ,arm64)
17+ LINUX_PLATFORM = @rules_go//go/toolchain:linux_arm64
18+ else
19+ LINUX_PLATFORM = @rules_go//go/toolchain:linux_amd64
20+ endif
21+
22+ .PHONY : build build-all-linux build-gateway-linux build-orchestrator-linux clean clean-proto deps e2e-test gazelle integration-test integration-test-extensions integration-test-gateway integration-test-orchestrator local-clean local-init-schemas local-logs local-ps local-restart local-start local-stop proto query-deps query-targets run-client-gateway run-client-orchestrator run-client-speculator test test-no-cache help
1723
1824
1925build : # # Build all services and examples
2026 @echo " Building all targets with Bazel..."
2127 @$(BAZEL ) build //...
2228 @echo " Build complete!"
2329
24- # Build Linux binaries required for Docker containers
30+ # Build Linux binaries required for Docker containers (local dev)
2531build-all-linux : build-gateway-linux build-orchestrator-linux # # Build all Linux binaries for Docker
2632 @echo " All Linux binaries ready for Docker"
2733
2834build-gateway-linux : # # Build Gateway Linux binary for Docker
29- @echo " Building Gateway Linux binary for Docker..."
30- @$(BAZEL ) build --platforms=@rules_go//go/toolchain:linux_amd64 //example/server/gateway:gateway
35+ @echo " Building Gateway Linux binary for Docker ( $( LINUX_PLATFORM ) ) ..."
36+ @$(BAZEL ) build --platforms=$( LINUX_PLATFORM ) //example/server/gateway:gateway
3137 @mkdir -p .docker-bin
3238 @cp -f bazel-bin/example/server/gateway/gateway_/gateway .docker-bin/gateway 2> /dev/null || \
3339 cp -f bazel-bin/example/server/gateway/gateway .docker-bin/gateway
3440 @echo " Gateway Linux binary ready at .docker-bin/gateway"
3541
3642build-orchestrator-linux : # # Build Orchestrator Linux binary for Docker
37- @echo " Building Orchestrator Linux binary for Docker..."
38- @$(BAZEL ) build --platforms=@rules_go//go/toolchain:linux_amd64 //example/server/orchestrator:orchestrator
43+ @echo " Building Orchestrator Linux binary for Docker ( $( LINUX_PLATFORM ) ) ..."
44+ @$(BAZEL ) build --platforms=$( LINUX_PLATFORM ) //example/server/orchestrator:orchestrator
3945 @mkdir -p .docker-bin
4046 @cp -f bazel-bin/example/server/orchestrator/orchestrator_/orchestrator .docker-bin/orchestrator 2> /dev/null || \
4147 cp -f bazel-bin/example/server/orchestrator/orchestrator .docker-bin/orchestrator
@@ -60,54 +66,41 @@ deps: ## Install Go dependencies
6066 @go mod tidy
6167 @echo " Dependencies installed!"
6268
63- e2e-test : build-all-linux # # Run end-to-end tests (hermetic, auto-builds binaries)
69+ # Common test flags for integration tests that use Docker containers.
70+ # --test_env passes env vars into the Bazel sandbox:
71+ # REPO_ROOT: locates pre-built Linux binaries in .docker-bin/
72+ # SKIP_CLEANUP: when "true", keeps containers running after tests for debugging
73+ TEST_FLAGS = --test_env=REPO_ROOT --test_env=SKIP_CLEANUP
74+
75+ e2e-test : build-all-linux # # Run end-to-end tests (Testcontainers-based)
6476 @echo " Running end-to-end tests..."
65- @$(BAZEL ) test //test/e2e:e2e_test --test_output=all
77+ @$(BAZEL ) test //test/e2e:e2e_test $( TEST_FLAGS ) --test_output=all
6678
6779gazelle : # # Update BUILD.bazel files
6880 @echo " Running Gazelle to update BUILD files..."
6981 @$(BAZEL ) run //:gazelle
7082
71- integration-test : build-all-linux # # Run all integration tests (auto-builds binaries )
83+ integration-test : build-all-linux # # Run all integration tests (Testcontainers-based )
7284 @echo " Running all integration tests..."
73- @$(BAZEL ) test //test/integration/... --test_output=errors
85+ @$(BAZEL ) test //test/integration/... $( TEST_FLAGS ) --test_output=errors
7486
7587integration-test-extensions : # # Run extension integration tests
7688 @echo " Running extension integration tests..."
77- @$(BAZEL ) test //test/integration/extension/... --test_output=errors
89+ @$(BAZEL ) test //test/integration/extension/... $( TEST_FLAGS ) --test_output=errors
7890
79- integration-test-gateway : build-gateway -linux # # Run Gateway integration tests (auto-builds binary)
91+ integration-test-gateway : build-all -linux # # Run Gateway integration tests
8092 @echo " Running Gateway integration tests..."
81- @$(BAZEL ) test //test/integration/gateway:gateway_test --test_output=errors
93+ @$(BAZEL ) test //test/integration/gateway:gateway_test $( TEST_FLAGS ) --test_output=errors
8294
83- integration-test-orchestrator : build-orchestrator -linux # # Run Orchestrator integration tests (auto-builds binary)
95+ integration-test-orchestrator : build-all -linux # # Run Orchestrator integration tests
8496 @echo " Running Orchestrator integration tests..."
85- @$(BAZEL ) test //test/integration/orchestrator:orchestrator_test --test_output=errors
97+ @$(BAZEL ) test //test/integration/orchestrator:orchestrator_test $( TEST_FLAGS ) --test_output=errors
8698
8799local-clean : # # Stop and remove all local services, volumes, and images
88100 @echo " Cleaning all services and data..."
89101 @$(COMPOSE ) -f $(COMPOSE_FILE ) -p $(LOCAL_PROJECT ) down -v --rmi local
90102 @echo " All services, volumes, and images removed."
91103
92- local-gateway-start : build-gateway-linux # # Start Gateway service locally (Gateway + 2 MySQL databases)
93- @echo " Starting Gateway with docker-compose..."
94- @$(COMPOSE ) -f $(GATEWAY_COMPOSE_FILE ) -p $(LOCAL_PROJECT ) up -d --build --wait
95- @echo " Applying database schemas..."
96- @$(MAKE ) -s local-init-schemas
97- @echo " "
98- @echo " ✅ Gateway is running!"
99- @echo " "
100- @$(COMPOSE ) -f $(GATEWAY_COMPOSE_FILE ) -p $(LOCAL_PROJECT ) ps
101- @echo " "
102- @echo " Gateway gRPC port: $$ (docker port $( LOCAL_PROJECT) -gateway-service-1 8080 2>/dev/null | cut -d: -f2 || echo 'unknown')"
103- @echo " MySQL App port: $$ (docker port $( LOCAL_PROJECT) -mysql-app-1 3306 2>/dev/null | cut -d: -f2 || echo 'unknown')"
104- @echo " MySQL Queue port: $$ (docker port $( LOCAL_PROJECT) -mysql-queue-1 3306 2>/dev/null | cut -d: -f2 || echo 'unknown')"
105-
106- local-gateway-stop : # # Stop Gateway service
107- @echo " Stopping Gateway services..."
108- @$(COMPOSE ) -f $(GATEWAY_COMPOSE_FILE ) -p $(LOCAL_PROJECT ) down
109- @echo " Gateway services stopped."
110-
111104local-init-schemas : # # Manually apply all database schemas
112105 @echo " Applying storage schema to mysql-app..."
113106 @for file in extension/storage/mysql/schema/* .sql; do \
@@ -124,44 +117,25 @@ local-init-schemas: ## Manually apply all database schemas
124117 echo " - Applying $$ (basename $$ file)..." ; \
125118 docker exec -i $(LOCAL_PROJECT ) -mysql-queue-1 mysql -uroot -proot submitqueue < $$ file 2>&1 | grep -v " Using a password" || true ; \
126119 done
127- @echo " ✅ All schemas applied successfully"
120+ @echo " All schemas applied successfully"
128121
129122local-logs : # # View logs from all running services
130123 @$(COMPOSE ) -f $(COMPOSE_FILE ) -p $(LOCAL_PROJECT ) logs -f
131124
132- local-orchestrator-start : build-orchestrator-linux # # Start Orchestrator service locally (Orchestrator + 2 MySQL databases)
133- @echo " Starting Orchestrator with docker-compose..."
134- @$(COMPOSE ) -f $(ORCHESTRATOR_COMPOSE_FILE ) -p $(LOCAL_PROJECT ) up -d --build --wait
135- @echo " Applying database schemas..."
136- @$(MAKE ) -s local-init-schemas
137- @echo " "
138- @echo " ✅ Orchestrator is running!"
139- @echo " "
140- @$(COMPOSE ) -f $(ORCHESTRATOR_COMPOSE_FILE ) -p $(LOCAL_PROJECT ) ps
141- @echo " "
142- @echo " Orchestrator gRPC port: $$ (docker port $( LOCAL_PROJECT) -orchestrator-service-1 8080 2>/dev/null | cut -d: -f2 || echo 'unknown')"
143- @echo " MySQL App port: $$ (docker port $( LOCAL_PROJECT) -mysql-app-1 3306 2>/dev/null | cut -d: -f2 || echo 'unknown')"
144- @echo " MySQL Queue port: $$ (docker port $( LOCAL_PROJECT) -mysql-queue-1 3306 2>/dev/null | cut -d: -f2 || echo 'unknown')"
145-
146- local-orchestrator-stop : # # Stop Orchestrator service
147- @echo " Stopping Orchestrator services..."
148- @$(COMPOSE ) -f $(ORCHESTRATOR_COMPOSE_FILE ) -p $(LOCAL_PROJECT ) down
149- @echo " Orchestrator services stopped."
150-
151125local-ps : # # Show running containers and their ports
152126 @echo " Running containers and ports:"
153127 @echo " "
154128 @$(COMPOSE ) -f $(COMPOSE_FILE ) -p $(LOCAL_PROJECT ) ps
155129 @echo " "
156- @echo " 📡 Service Endpoints:"
130+ @echo " Service Endpoints:"
157131 @echo " Gateway gRPC: localhost:$$ (docker port $( LOCAL_PROJECT) -gateway-service-1 8080 2>/dev/null | cut -d: -f2 || echo 'not running')"
158132 @echo " Orchestrator gRPC: localhost:$$ (docker port $( LOCAL_PROJECT) -orchestrator-service-1 8080 2>/dev/null | cut -d: -f2 || echo 'not running')"
159133 @echo " "
160- @echo " 🗄️ Database Endpoints:"
134+ @echo " Database Endpoints:"
161135 @echo " MySQL App: localhost:$$ (docker port $( LOCAL_PROJECT) -mysql-app-1 3306 2>/dev/null | cut -d: -f2 || echo 'not running')"
162136 @echo " MySQL Queue: localhost:$$ (docker port $( LOCAL_PROJECT) -mysql-queue-1 3306 2>/dev/null | cut -d: -f2 || echo 'not running')"
163137 @echo " "
164- @echo " 💡 Usage:"
138+ @echo " Usage:"
165139 @echo " # Connect to MySQL App DB"
166140 @echo " mysql -h127.0.0.1 -P$$ (docker port $( LOCAL_PROJECT) -mysql-app-1 3306 2>/dev/null | cut -d: -f2 || echo 'PORT') -uroot -proot submitqueue"
167141 @echo " "
@@ -183,7 +157,7 @@ local-start: build-all-linux ## Start full stack (Gateway + Orchestrator + MySQL
183157 @echo " Applying database schemas..."
184158 @$(MAKE ) -s local-init-schemas
185159 @echo " "
186- @echo " ✅ Full stack is running!"
160+ @echo " Full stack is running!"
187161 @echo " "
188162 @make local-ps
189163
@@ -239,4 +213,3 @@ help: ## Show this help message
239213 @echo " Available targets:"
240214 @echo " "
241215 @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
242-
0 commit comments