| #!/usr/bin/env bash |
| set -euo pipefail |
|
|
| |
| |
|
|
| echo "π§ͺ Starting Bifrost Test Suite..." |
| echo "==================================" |
|
|
| |
| RED='\033[0;31m' |
| GREEN='\033[0;32m' |
| YELLOW='\033[1;33m' |
| NC='\033[0m' |
|
|
| |
| TESTS_PASSED=0 |
| TESTS_FAILED=0 |
|
|
| |
| report_result() { |
| local test_name=$1 |
| local result=$2 |
| |
| if [ "$result" -eq 0 ]; then |
| echo -e "${GREEN}β
$test_name passed${NC}" |
| ((TESTS_PASSED++)) |
| else |
| echo -e "${RED}β $test_name failed${NC}" |
| ((TESTS_FAILED++)) |
| fi |
| } |
|
|
| |
| echo "" |
| echo "π¦ 1/5 - Validating Core Build..." |
| echo "-----------------------------------" |
| cd core |
| if go mod download && go build ./...; then |
| report_result "Core Build" 0 |
| else |
| report_result "Core Build" 1 |
| fi |
| cd .. |
|
|
| |
| echo "" |
| echo "π 2/5 - Building MCP Test Servers..." |
| echo "-----------------------------------" |
| MCP_BUILD_FAILED=0 |
| for mcp_dir in examples/mcps/*/; do |
| if [ -d "$mcp_dir" ]; then |
| mcp_name=$(basename "$mcp_dir") |
| if [ -f "$mcp_dir/go.mod" ]; then |
| echo " Building $mcp_name (Go)..." |
| mkdir -p "$mcp_dir/bin" |
| if cd "$mcp_dir" && GOWORK=off go build -o "bin/$mcp_name" . && cd - > /dev/null; then |
| echo -e " ${GREEN}β $mcp_name${NC}" |
| else |
| echo -e " ${RED}β $mcp_name${NC}" |
| MCP_BUILD_FAILED=1 |
| cd - > /dev/null 2>&1 || true |
| fi |
| elif [ -f "$mcp_dir/package.json" ]; then |
| echo " Building $mcp_name (TypeScript)..." |
| if cd "$mcp_dir" && npm install --silent && npm run build && cd - > /dev/null; then |
| echo -e " ${GREEN}β $mcp_name${NC}" |
| else |
| echo -e " ${RED}β $mcp_name${NC}" |
| MCP_BUILD_FAILED=1 |
| cd - > /dev/null 2>&1 || true |
| fi |
| fi |
| fi |
| done |
| report_result "MCP Test Servers Build" $MCP_BUILD_FAILED |
|
|
| |
| echo "" |
| echo "π§ 3/5 - Running Core Provider Tests..." |
| echo "-----------------------------------" |
| cd core |
| if go test -v -run . ./...; then |
| report_result "Core Provider Tests" 0 |
| else |
| report_result "Core Provider Tests" 1 |
| fi |
| cd .. |
|
|
| |
| echo "" |
| echo "π‘οΈ 4/5 - Running Governance Tests..." |
| echo "-----------------------------------" |
| if [ -d "tests/governance" ]; then |
| cd tests/governance |
| |
| |
| if [ ! -d "venv" ]; then |
| echo "Creating Python virtual environment..." |
| python3 -m venv venv |
| fi |
| |
| |
| source venv/bin/activate |
| |
| |
| echo "Installing Python dependencies..." |
| pip install -q -r requirements.txt |
| |
| |
| if pytest -v; then |
| report_result "Governance Tests" 0 |
| else |
| report_result "Governance Tests" 1 |
| fi |
| |
| deactivate |
| cd ../.. |
| else |
| echo -e "${YELLOW}β οΈ Governance tests directory not found, skipping...${NC}" |
| fi |
|
|
| |
| echo "" |
| echo "π 5/5 - Running Integration Tests..." |
| echo "-----------------------------------" |
| if [ -d "tests/integrations" ]; then |
| cd tests/integrations |
| |
| |
| if [ ! -d "venv" ]; then |
| echo "Creating Python virtual environment..." |
| python3 -m venv venv |
| fi |
| |
| |
| source venv/bin/activate |
| |
| |
| echo "Installing Python dependencies..." |
| pip install -q -r requirements.txt |
| |
| |
| if python run_all_tests.py; then |
| report_result "Integration Tests" 0 |
| else |
| report_result "Integration Tests" 1 |
| fi |
| |
| deactivate |
| cd ../.. |
| else |
| echo -e "${YELLOW}β οΈ Integration tests directory not found, skipping...${NC}" |
| fi |
|
|
| |
| echo "" |
| echo "==================================" |
| echo "π Test Suite Complete!" |
| echo "==================================" |
| echo -e "${GREEN}Passed: $TESTS_PASSED${NC}" |
| echo -e "${RED}Failed: $TESTS_FAILED${NC}" |
| echo "" |
|
|
| if [ "$TESTS_FAILED" -gt 0 ]; then |
| echo -e "${RED}β Some tests failed. Please review the output above.${NC}" |
| exit 1 |
| else |
| echo -e "${GREEN}β
All tests passed successfully!${NC}" |
| exit 0 |
| fi |
|
|
|
|