-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_build_verification.sh
executable file
·212 lines (183 loc) · 6.56 KB
/
run_build_verification.sh
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/bin/bash
# End-to-End Build Verification Script
#
# This script automates the process of verifying an end-to-end build by:
# 1. First analyzing the codebase to store component relationships
# 2. Triggering the build verification process
# 3. Reporting the results
set -e
# Set up environment
source .venv/bin/activate || source test_env/bin/activate || echo "No virtual environment found, using system Python"
# Create required directories
mkdir -p logs knowledge cache
# Set environment variables for testing
export MCP_EMBEDDING_TIMEOUT=120 # Increase timeout for embedder initialization
export QDRANT_URL="${QDRANT_URL:-http://localhost:6333}"
export QDRANT_API_KEY="${QDRANT_API_KEY:-}"
export MCP_COLLECTION_NAME="${MCP_COLLECTION_NAME:-mcp-codebase-insight}"
# Default values
CONFIG_FILE="verification-config.json"
OUTPUT_FILE="logs/build_verification_report.json"
ANALYZE_FIRST=true
VERBOSE=false
# Check if Qdrant is running locally
check_qdrant() {
if curl -s "http://localhost:6333/collections" > /dev/null; then
echo "Local Qdrant instance detected"
return 0
else
echo "Warning: No local Qdrant instance found at http://localhost:6333"
echo "You may need to start Qdrant using Docker:"
echo "docker run -p 6333:6333 qdrant/qdrant"
return 1
fi
}
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--config)
CONFIG_FILE="$2"
shift 2
;;
--output)
OUTPUT_FILE="$2"
shift 2
;;
--skip-analysis)
ANALYZE_FIRST=false
shift
;;
--verbose)
VERBOSE=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--config CONFIG_FILE] [--output OUTPUT_FILE] [--skip-analysis] [--verbose]"
exit 1
;;
esac
done
# Set up logging
LOG_FILE="logs/build_verification.log"
if $VERBOSE; then
# Log to both console and file
exec > >(tee -a "$LOG_FILE") 2>&1
else
# Log only to file
exec >> "$LOG_FILE" 2>&1
fi
echo "==================================================================="
echo "Starting End-to-End Build Verification at $(date)"
echo "==================================================================="
echo "Config file: $CONFIG_FILE"
echo "Output file: $OUTPUT_FILE"
echo "Analyze first: $ANALYZE_FIRST"
echo "Verbose mode: $VERBOSE"
echo "-------------------------------------------------------------------"
# Check if config file exists
if [[ ! -f "$CONFIG_FILE" ]]; then
echo "Error: Config file $CONFIG_FILE not found!"
exit 1
fi
# Function to check if a command is available
check_command() {
if ! command -v "$1" &> /dev/null; then
echo "Error: $1 is required but not installed."
exit 1
fi
}
# Check required commands
check_command python
check_command pip
# Ensure all dependencies are installed
echo "Checking dependencies..."
pip install -q -r requirements.txt
pip install -q -e .
# Step 1: Check Qdrant availability
echo "Checking Qdrant availability..."
if ! check_qdrant; then
if [[ "$QDRANT_URL" == "http://localhost:6333" ]]; then
echo "Error: Local Qdrant instance is not running and no alternative QDRANT_URL is set"
echo "Please either:"
echo "1. Start a local Qdrant instance using Docker:"
echo " docker run -p 6333:6333 qdrant/qdrant"
echo "2. Or set QDRANT_URL to point to your Qdrant instance"
exit 1
else
echo "Using alternative Qdrant instance at $QDRANT_URL"
fi
fi
# Step 2: Analyze codebase and store component relationships (if enabled)
if $ANALYZE_FIRST; then
echo "Analyzing codebase and storing component relationships..."
python -m scripts.store_code_relationships --config "$CONFIG_FILE"
if [[ $? -ne 0 ]]; then
echo "Error: Failed to analyze codebase and store component relationships!"
exit 1
fi
echo "Component relationships analysis completed successfully."
else
echo "Skipping codebase analysis as requested."
fi
# Step 3: Run build verification
echo "Running tests with standardized test runner..."
chmod +x run_tests.py
./run_tests.py --all --clean --isolated --coverage --html --verbose
TEST_EXIT_CODE=$?
echo "Running build verification..."
python -m scripts.verify_build --config "$CONFIG_FILE" --output "$OUTPUT_FILE"
BUILD_STATUS=$?
# Use the worst exit code between tests and build verification
if [ $TEST_EXIT_CODE -ne 0 ]; then
BUILD_STATUS=$TEST_EXIT_CODE
fi
if [[ $BUILD_STATUS -ne 0 ]]; then
echo "Build verification failed with exit code $BUILD_STATUS!"
else
echo "Build verification completed successfully."
fi
# Step 4: Report results
echo "Build verification report saved to $OUTPUT_FILE"
if [[ -f "$OUTPUT_FILE" ]]; then
# Extract summary from report if jq is available
if command -v jq &> /dev/null; then
SUMMARY=$(jq -r '.build_verification_report.summary' "$OUTPUT_FILE")
STATUS=$(jq -r '.build_verification_report.verification_results.overall_status' "$OUTPUT_FILE")
echo "-------------------------------------------------------------------"
echo "Build Verification Status: $STATUS"
echo "Summary: $SUMMARY"
echo "-------------------------------------------------------------------"
# Print test results
TOTAL=$(jq -r '.build_verification_report.test_summary.total' "$OUTPUT_FILE")
PASSED=$(jq -r '.build_verification_report.test_summary.passed' "$OUTPUT_FILE")
FAILED=$(jq -r '.build_verification_report.test_summary.failed' "$OUTPUT_FILE")
COVERAGE=$(jq -r '.build_verification_report.test_summary.coverage' "$OUTPUT_FILE")
echo "Test Results:"
echo "- Total Tests: $TOTAL"
echo "- Passed: $PASSED"
echo "- Failed: $FAILED"
echo "- Coverage: $COVERAGE%"
# Print failure info if any
if [[ "$STATUS" != "PASS" ]]; then
echo "-------------------------------------------------------------------"
echo "Failures detected. See $OUTPUT_FILE for details."
# Print failure analysis if available
if jq -e '.build_verification_report.failure_analysis' "$OUTPUT_FILE" > /dev/null; then
echo "Failure Analysis:"
jq -r '.build_verification_report.failure_analysis[] | "- " + .description' "$OUTPUT_FILE"
fi
fi
else
echo "-------------------------------------------------------------------"
echo "Install jq for better report formatting."
echo "Report saved to $OUTPUT_FILE"
fi
else
echo "Error: Build verification report not found at $OUTPUT_FILE!"
fi
echo "==================================================================="
echo "End-to-End Build Verification completed at $(date)"
echo "Exit status: $BUILD_STATUS"
echo "==================================================================="
exit $BUILD_STATUS