forked from maximhq/bifrost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·172 lines (148 loc) · 4.13 KB
/
Copy pathrun-tests.sh
File metadata and controls
executable file
·172 lines (148 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env bash
set -euo pipefail
# Comprehensive test runner for Bifrost PR validation
# This script runs all test suites to validate changes
echo "🧪 Starting Bifrost Test Suite..."
echo "=================================="
# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Track test results
TESTS_PASSED=0
TESTS_FAILED=0
# Function to report test result
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
}
# 1. Core Build Validation
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 ..
# 2. Build MCP Test Servers
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
# 3. Core Provider Tests
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 ..
# 4. Governance Tests
echo ""
echo "🛡️ 4/5 - Running Governance Tests..."
echo "-----------------------------------"
if [ -d "tests/governance" ]; then
cd tests/governance
# Check if virtual environment exists, create if not
if [ ! -d "venv" ]; then
echo "Creating Python virtual environment..."
python3 -m venv venv
fi
# Activate virtual environment
source venv/bin/activate
# Install dependencies
echo "Installing Python dependencies..."
pip install -q -r requirements.txt
# Run tests
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
# 5. Integration Tests
echo ""
echo "🔗 5/5 - Running Integration Tests..."
echo "-----------------------------------"
if [ -d "tests/integrations" ]; then
cd tests/integrations
# Check if virtual environment exists, create if not
if [ ! -d "venv" ]; then
echo "Creating Python virtual environment..."
python3 -m venv venv
fi
# Activate virtual environment
source venv/bin/activate
# Install dependencies
echo "Installing Python dependencies..."
pip install -q -r requirements.txt
# Run tests
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
# Final Summary
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