/ Makefile
Makefile
1 .PHONY: help check-uv dev-setup test-setup test test-all test-eval test-eval-local test-eval-workflow test-eval-remote test-unit test-integration test-migrations clean ui-test ui-build ui-lint install-playwright 2 3 # Check if uv is installed 4 check-uv: 5 @which uv > /dev/null || (echo "Error: 'uv' is not installed. Install it with: curl -LsSf https://astral.sh/uv/install.sh | sh" && exit 1) 6 7 # Default target 8 help: 9 @echo "Solace Agent Mesh - Dev Commands" 10 @echo "" 11 @echo "Setup:" 12 @echo " make dev-setup Set up development environment with Python 3.12" 13 @echo " make test-setup Install all test dependencies (mirrors CI setup)" 14 @echo " make install-playwright Install Playwright browsers" 15 @echo "" 16 @echo "Backend Tests:" 17 @echo " make test Run all tests (excluding stress/long_soak)" 18 @echo " make test-all Run all tests including stress and evaluation tests" 19 @echo " make test-eval Run local evaluation tests (default)" 20 @echo " make test-eval-local Run local evaluation tests" 21 @echo " make test-eval-workflow Run workflow evaluation tests" 22 @echo " make test-eval-remote Run remote evaluation tests" 23 @echo " make test-unit Run unit tests only" 24 @echo " make test-integration Run integration tests only" 25 @echo " make test-migrations Run database migration tests (SQLite, MySQL, PostgreSQL)" 26 @echo "" 27 @echo "Frontend Tests:" 28 @echo " make ui-test Run frontend linting and build" 29 @echo " make ui-lint Run frontend linting only" 30 @echo " make ui-build Build frontend packages" 31 @echo "" 32 @echo "Cleanup:" 33 @echo " make clean Clean up test artifacts and cache" 34 @echo "" 35 36 # Set up development environment 37 dev-setup: check-uv 38 @echo "Setting up development environment..." 39 UV_VENV_CLEAR=1 uv venv --python 3.12 40 @echo "Syncing dependencies with all extras..." 41 uv sync --all-extras 42 @echo "Installing test infrastructure..." 43 uv pip install -e tests/sam-test-infrastructure 44 @echo "Installing Playwright browsers..." 45 uv run playwright install 46 @echo "Development environment setup complete!" 47 @echo "To activate the virtual environment, run: source .venv/bin/activate" 48 49 # Setup test environment 50 test-setup: check-uv 51 @echo "Installing test dependencies..." 52 uv pip install -e ".[gcs,vertex,employee_tools,test]" 53 uv pip install -e tests/sam-test-infrastructure 54 @echo "Installing Playwright browsers..." 55 uv run playwright install 56 @echo "Test environment setup complete!" 57 58 # Setup eval environment 59 # Note: Uses wheel build instead of editable install because hatchling's editable mode 60 # doesn't support force-include for cli/, evaluation/, etc. directories outside src/ 61 eval-setup: check-uv 62 @echo "Setting up evaluation test environment..." 63 UV_VENV_CLEAR=1 uv venv --python 3.12 64 @echo "Building wheel directly (skipping UI builds and sdist for speed)..." 65 SAM_SKIP_UI_BUILD=true uv build --wheel 66 @echo "Installing Solace Agent Mesh from wheel..." 67 uv pip install "$$(ls dist/solace_agent_mesh-*.whl | head -1)" --reinstall 68 @echo "Installing sam-rest-gateway plugin for local evaluations..." 69 uv pip install sam-rest-gateway 70 @echo "Installing Playwright browsers..." 71 .venv/bin/playwright install 72 73 # Install Playwright browsers only 74 install-playwright: check-uv 75 @echo "Installing Playwright browsers..." 76 uv run playwright install 77 78 # Run tests excluding stress and long_soak (default for development) 79 test: 80 @echo "Running tests (excluding stress and long_soak)..." 81 uv run pytest -m "not stress and not long_soak" 82 83 # Run all tests 84 test-all: 85 @echo "Running tests in parallel..." 86 uv run pytest tests -n auto --maxprocesses=2 --dist loadgroup -v 87 88 # Helper target to validate required environment variables 89 check-eval-env: 90 @echo "Validating required environment variables..." 91 @test -n "$(SOLACE_BROKER_URL)" || (echo "ERROR: SOLACE_BROKER_URL not set. Export it before running make" && exit 1) 92 @test -n "$(SOLACE_BROKER_USERNAME)" || (echo "ERROR: SOLACE_BROKER_USERNAME not set. Export it before running make" && exit 1) 93 @test -n "$(SOLACE_BROKER_PASSWORD)" || (echo "ERROR: SOLACE_BROKER_PASSWORD not set. Export it before running make" && exit 1) 94 @test -n "$(SOLACE_BROKER_VPN)" || (echo "ERROR: SOLACE_BROKER_VPN not set. Export it before running make" && exit 1) 95 @test -n "$(LLM_SERVICE_ENDPOINT)" || (echo "ERROR: LLM_SERVICE_ENDPOINT not set. Export it before running make" && exit 1) 96 @test -n "$(LLM_SERVICE_API_KEY)" || (echo "ERROR: LLM_SERVICE_API_KEY not set. Export it before running make" && exit 1) 97 @echo "✓ All required environment variables are set" 98 99 100 check-remote-eval-env: 101 @echo "Validating required environment variables..." 102 @test -n "$(EVAL_REMOTE_URL)" || (echo "ERROR: EVAL_REMOTE_URL not set. Export it before running make" && exit 1) 103 @test -n "$(EVAL_NAMESPACE)" || (echo "ERROR: EVAL_NAMESPACE not set. Export it before running make" && exit 1) 104 @test -n "$(EVAL_AUTH_TOKEN)" || (echo "ERROR: EVAL_AUTH_TOKEN not set. Export it before running make" && exit 1) 105 @echo "✓ All required remote environment variables are set" 106 107 # Define env vars to pass through to eval commands 108 EVAL_ENV_VARS = SOLACE_BROKER_URL="$(SOLACE_BROKER_URL)" \ 109 SOLACE_BROKER_USERNAME="$(SOLACE_BROKER_USERNAME)" \ 110 SOLACE_BROKER_PASSWORD="$(SOLACE_BROKER_PASSWORD)" \ 111 SOLACE_BROKER_VPN="$(SOLACE_BROKER_VPN)" \ 112 LLM_SERVICE_ENDPOINT="$(LLM_SERVICE_ENDPOINT)" \ 113 LLM_SERVICE_API_KEY="$(LLM_SERVICE_API_KEY)" 114 115 116 # Define env vars to pass through to eval commands 117 REMOTE_EVAL_ENV_VARS = EVAL_REMOTE_URL="$(EVAL_REMOTE_URL)" \ 118 EVAL_NAMESPACE="$(EVAL_NAMESPACE)" \ 119 EVAL_AUTH_TOKEN="$(EVAL_AUTH_TOKEN)" 120 121 # Run evaluation tests (default: local) 122 test-eval: test-eval-local 123 124 # Run local evaluation tests 125 test-eval-local: eval-setup check-eval-env 126 @echo "Running local evaluation tests..." 127 @echo "" 128 $(EVAL_ENV_VARS) .venv/bin/sam eval tests/evaluation/local_example.json -v 129 130 # Run workflow evaluation tests 131 test-eval-workflow: eval-setup check-eval-env 132 @echo "Running workflow evaluation tests..." 133 @echo "" 134 $(EVAL_ENV_VARS) .venv/bin/sam eval tests/evaluation/workflow_eval.json 135 136 # Run remote evaluation tests 137 test-eval-remote: eval-setup check-eval-env check-remote-eval-env 138 @echo "Running remote evaluation tests..." 139 @echo "" 140 $(EVAL_ENV_VARS) $(REMOTE_EVAL_ENV_VARS) .venv/bin/sam eval tests/evaluation/remote_example.json -v 141 142 # Run unit tests only 143 test-unit: 144 @echo "Running unit tests..." 145 uv run pytest tests/unit -v 146 147 # Run integration tests only 148 test-integration: 149 @echo "Running integration tests..." 150 uv run pytest tests/integration -v 151 152 # Run database migration tests (auto-installs deps, auto-manages containers) 153 test-migrations: check-uv 154 @echo "Installing migration test dependencies..." 155 @uv pip install pytest testcontainers[postgres] testcontainers[mysql] pymysql psycopg2-binary alembic 2>/dev/null || true 156 @echo "" 157 @echo "Running migration tests (containers start automatically)..." 158 @echo "Testing: SQLite, MySQL, PostgreSQL" 159 @echo "" 160 PYTHONPATH=. uv run pytest tests/integration/migrations/ -v -x 161 162 # Frontend linting (mirrors ui-ci.yml) 163 ui-lint: 164 @echo "Running frontend linting..." 165 cd client/webui/frontend && npm run lint 166 167 # Build frontend packages (mirrors ui-ci.yml) 168 ui-build: 169 @echo "Building frontend packages..." 170 cd client/webui/frontend && npm run build-package 171 cd client/webui/frontend && npm run build-storybook 172 173 # Run frontend tests (lint + build) 174 ui-test: ui-lint ui-build 175 @echo "Frontend tests completed!" 176 177 # Clean up test artifacts 178 clean: 179 @echo "Cleaning up test artifacts..." 180 find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true 181 find . -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true 182 find . -type f -name '*.pyc' -delete 2>/dev/null || true 183 @echo "Cleanup complete!"