Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pkg
bin
.git
.idea
7 changes: 2 additions & 5 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
GOPATH=$(pwd)
export GOPATH
PATH_add tools


WORKSPACE_ROOT=$(pwd)
export WORKSPACE_ROOT
REPO_ROOT=$(pwd)
export REPO_ROOT
50 changes: 50 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Test

on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build all services
run: make build

- name: Run unit tests
run: make test || echo "No tests found yet"

- name: Start all servers
run: make start-servers

- name: Run service integration tests
run: make integration-test

- name: Run end-to-end tests
run: make e2e-test

- name: Stop servers
if: always()
run: make stop-servers

- name: Display server logs on failure
if: failure()
run: |
echo "=== Gateway logs ==="
cat /tmp/gateway.log || echo "No gateway logs found"
echo ""
echo "=== Orchestrator logs ==="
cat /tmp/orchestrator.log || echo "No orchestrator logs found"
echo ""
echo "=== Speculator logs ==="
cat /tmp/speculator.log || echo "No speculator logs found"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ MODULE.bazel.lock
.vscode/
.idea/
.claude/
.ijwb/


# Built binaries
Expand Down
8 changes: 2 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
module(
name = "submitqueue",
version = "0.1.0",
bazel_compatibility = [">=7.0.0"],
)

bazel_dep(name = "rules_go", version = "0.57.0")
bazel_dep(name = "gazelle", version = "0.45.0")
bazel_dep(name = "rules_proto", version = "7.1.0")
Expand Down Expand Up @@ -37,8 +31,10 @@ go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_github_gogo_protobuf",
"com_github_uber_go_tally_v4",
"org_golang_google_grpc",
"org_golang_google_protobuf",
"org_uber_go_fx",
"org_uber_go_yarpc",
"org_uber_go_zap",
)
119 changes: 98 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: proto build test clean run-gateway run-orchestrator run-speculator run-client-gateway run-client-orchestrator run-client-speculator
.PHONY: proto build test integration-test integration-test-gateway integration-test-orchestrator integration-test-speculator e2e-test gazelle clean run-all start-servers stop-servers run-gateway run-orchestrator run-speculator run-client-gateway run-client-orchestrator run-client-speculator

# Bazel wrapper
BAZEL = ./tools/bazel
Expand All @@ -20,19 +20,10 @@ proto:
--proto_path=speculator/proto speculator/proto/speculator.proto
@echo "Protobuf files generated successfully!"

# Build all services and examples using Bazel
# Build everything in the project using Bazel
build:
@echo "Building all services with Bazel..."
@$(BAZEL) build //gateway:gateway
@$(BAZEL) build //orchestrator:orchestrator
@$(BAZEL) build //speculator:speculator
@echo "Building example servers and clients..."
@$(BAZEL) build //examples/server/gateway:gateway
@$(BAZEL) build //examples/server/orchestrator:orchestrator
@$(BAZEL) build //examples/server/speculator:speculator
@$(BAZEL) build //examples/client/gateway:gateway
@$(BAZEL) build //examples/client/orchestrator:orchestrator
@$(BAZEL) build //examples/client/speculator:speculator
@echo "Building all targets with Bazel..."
@$(BAZEL) build //...
@echo "Copying binaries to ./bin/..."
@mkdir -p bin
@cp -f bazel-bin/examples/server/gateway/gateway_/gateway bin/gateway_server 2>/dev/null || \
Expand All @@ -49,9 +40,38 @@ build:
cp -f bazel-bin/examples/client/speculator/speculator bin/speculator_client 2>/dev/null || true
@echo "Build complete! Binaries are in ./bin/"

# Run tests using Bazel
# Run unit tests using Bazel (excludes integration tests which require running servers)
test:
@$(BAZEL) test //...
@echo "Running unit tests..."
@$(BAZEL) test //... --test_tag_filters=-manual,-integration || echo "No unit tests found (only integration tests exist)"

# Generate/update BUILD.bazel files using Gazelle
gazelle:
@echo "Running Gazelle to update BUILD files..."
@$(BAZEL) run //:gazelle

# Run integration tests for a specific service (requires that service to be running)
integration-test-gateway:
@echo "Running Gateway integration tests..."
@$(BAZEL) test //gateway/integration_tests:integration_test --test_output=all

integration-test-orchestrator:
@echo "Running Orchestrator integration tests..."
@$(BAZEL) test //orchestrator/integration_tests:integration_test --test_output=all

integration-test-speculator:
@echo "Running Speculator integration tests..."
@$(BAZEL) test //speculator/integration_tests:integration_test --test_output=all

# Run all service integration tests (requires all services to be running)
integration-test:
@echo "Running all service integration tests..."
@$(BAZEL) test //gateway/integration_tests:integration_test //orchestrator/integration_tests:integration_test //speculator/integration_tests:integration_test --test_output=all

# Run end-to-end tests (requires all services to be running)
e2e-test:
@echo "Running end-to-end tests..."
@$(BAZEL) test //integration_tests:e2e_test --test_output=all

# Clean generated files and binaries
clean:
Expand All @@ -68,6 +88,39 @@ clean-proto:
@rm -rf speculator/protopb/*.pb.go
@echo "Proto clean complete!"

# Start all servers in background (for testing)
start-servers:
@echo "Starting all servers in background..."
@./bin/gateway_server > /tmp/gateway.log 2>&1 & echo $$! > /tmp/gateway.pid
@./bin/orchestrator_server > /tmp/orchestrator.log 2>&1 & echo $$! > /tmp/orchestrator.pid
@./bin/speculator_server > /tmp/speculator.log 2>&1 & echo $$! > /tmp/speculator.pid
@sleep 2
@echo "All servers started:"
@echo " Gateway (PID: $$(cat /tmp/gateway.pid)) - http://localhost:8081"
@echo " Orchestrator (PID: $$(cat /tmp/orchestrator.pid)) - http://localhost:8082"
@echo " Speculator (PID: $$(cat /tmp/speculator.pid)) - http://localhost:8083"
@echo ""
@echo "Logs:"
@echo " tail -f /tmp/gateway.log"
@echo " tail -f /tmp/orchestrator.log"
@echo " tail -f /tmp/speculator.log"
@echo ""
@echo "To stop: make stop-servers"

# Stop all background servers
stop-servers:
@echo "Stopping all servers..."
@if [ -f /tmp/gateway.pid ]; then kill $$(cat /tmp/gateway.pid) 2>/dev/null || true; rm -f /tmp/gateway.pid; fi
@if [ -f /tmp/orchestrator.pid ]; then kill $$(cat /tmp/orchestrator.pid) 2>/dev/null || true; rm -f /tmp/orchestrator.pid; fi
@if [ -f /tmp/speculator.pid ]; then kill $$(cat /tmp/speculator.pid) 2>/dev/null || true; rm -f /tmp/speculator.pid; fi
@echo "All servers stopped"

# Run all servers (for testing) - starts servers, waits for Ctrl+C, then stops
run-all: start-servers
@echo ""
@echo "Press Ctrl+C to stop all servers..."
@trap 'make stop-servers' INT; while true; do sleep 1; done

# Run gateway server using Bazel
run-gateway:
@echo "Starting gateway server on port 8081..."
Expand Down Expand Up @@ -112,20 +165,44 @@ query-deps:
# Help
help:
@echo "Available targets:"
@echo " make proto - Generate protobuf files (using Bazel)"
@echo " make build - Build all services and examples (using Bazel)"
@echo " make test - Run tests (using Bazel)"
@echo ""
@echo "Build & Test:"
@echo " make proto - Generate protobuf files"
@echo " make build - Build all services and examples"
@echo " make test - Run unit tests"
@echo " make gazelle - Update BUILD.bazel files"
@echo " make clean - Clean generated files and binaries"
@echo ""
@echo "Run Servers:"
@echo " make run-all - Run all servers (Ctrl+C to stop)"
@echo " make start-servers - Start all servers in background"
@echo " make stop-servers - Stop all background servers"
@echo " make run-gateway - Run gateway server (port 8081)"
@echo " make run-orchestrator - Run orchestrator server (port 8082)"
@echo " make run-speculator - Run speculator server (port 8083)"
@echo " make run-client-gateway - Run gateway client (use SERVER_ADDR= and MESSAGE=)"
@echo ""
@echo "Integration Tests (requires servers to be running):"
@echo " make integration-test-gateway - Test Gateway service"
@echo " make integration-test-orchestrator - Test Orchestrator service"
@echo " make integration-test-speculator - Test Speculator service"
@echo " make integration-test - Test all services"
@echo " make e2e-test - Run end-to-end tests"
@echo ""
@echo "Run Clients:"
@echo " make run-client-gateway - Run gateway client"
@echo " make run-client-orchestrator - Run orchestrator client"
@echo " make run-client-speculator - Run speculator client"
@echo ""
@echo "Other:"
@echo " make deps - Install Go dependencies"
@echo " make query-targets - List all Bazel targets"
@echo " make query-deps - Show dependencies for gateway server"
@echo ""
@echo "Examples:"
@echo " # Start all servers and run integration tests"
@echo " make build && make start-servers && make integration-test && make stop-servers"
@echo ""
@echo " # Run a single server"
@echo " make run-gateway"
@echo " make run-client-gateway SERVER_ADDR=localhost:8081 MESSAGE='hello gateway'"
@echo ""
@echo " # Test with custom message"
@echo " make run-client-gateway MESSAGE='hello gateway'"
Loading