Skip to content

Commit 9bddc9a

Browse files
523034406523034406
authored andcommitted
feat: add health check script
1 parent 2b5fcf9 commit 9bddc9a

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

scripts/health_check.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
# SoloFlow Health Check Script
3+
4+
echo "=== SoloFlow Health Check ==="
5+
echo ""
6+
7+
# Run tests
8+
echo "1. Running tests..."
9+
python -m pytest tests/ -q
10+
if [ $? -eq 0 ]; then
11+
echo " ✅ All tests pass"
12+
else
13+
echo " ❌ Tests failed"
14+
exit 1
15+
fi
16+
17+
# Check type hints
18+
echo ""
19+
echo "2. Checking type hints..."
20+
python -c "
21+
import ast
22+
import os
23+
24+
def check_type_hints(filepath):
25+
with open(filepath, 'r') as f:
26+
tree = ast.parse(f.read())
27+
28+
functions = [node for node in ast.walk(tree) if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))]
29+
annotated = sum(1 for f in functions if f.returns is not None)
30+
31+
return annotated, len(functions)
32+
33+
files = []
34+
for root, dirs, filenames in os.walk('hermes-plugin'):
35+
for filename in filenames:
36+
if filename.endswith('.py') and '__pycache__' not in root:
37+
files.append(os.path.join(root, filename))
38+
39+
total_annotated = 0
40+
total_functions = 0
41+
42+
for filepath in files:
43+
try:
44+
annotated, functions = check_type_hints(filepath)
45+
total_annotated += annotated
46+
total_functions += functions
47+
except Exception as e:
48+
pass
49+
50+
if total_functions > 0:
51+
coverage = total_annotated / total_functions * 100
52+
print(f' Type hint coverage: {coverage:.1f}%')
53+
if coverage >= 90:
54+
print(' ✅ Good coverage')
55+
else:
56+
print(' ⚠️ Consider adding more type hints')
57+
else:
58+
print(' No functions found')
59+
"
60+
61+
# Check docstrings
62+
echo ""
63+
echo "3. Checking docstrings..."
64+
python -c "
65+
import ast
66+
import os
67+
68+
def check_docstrings(filepath):
69+
with open(filepath, 'r') as f:
70+
tree = ast.parse(f.read())
71+
72+
functions = [node for node in ast.walk(tree) if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))]
73+
documented = sum(1 for f in functions if ast.get_docstring(f))
74+
75+
return documented, len(functions)
76+
77+
files = []
78+
for root, dirs, filenames in os.walk('hermes-plugin'):
79+
for filename in filenames:
80+
if filename.endswith('.py') and '__pycache__' not in root:
81+
files.append(os.path.join(root, filename))
82+
83+
total_documented = 0
84+
total_functions = 0
85+
86+
for filepath in files:
87+
try:
88+
documented, functions = check_docstrings(filepath)
89+
total_documented += documented
90+
total_functions += functions
91+
except Exception as e:
92+
pass
93+
94+
if total_functions > 0:
95+
coverage = total_documented / total_functions * 100
96+
print(f' Docstring coverage: {coverage:.1f}%')
97+
if coverage >= 80:
98+
print(' ✅ Good coverage')
99+
else:
100+
print(' ⚠️ Consider adding more docstrings')
101+
else:
102+
print(' No functions found')
103+
"
104+
105+
echo ""
106+
echo "=== Health Check Complete ==="

0 commit comments

Comments
 (0)