Spaces:
Build error
Build error
Commit ·
4f306fa
1
Parent(s): 9fc4f78
fix(ci): extract route check to scripts/verify_routes.py
Browse filesThe inline python3 -c block in test.yml contained a non-UTF-8 byte
(0x97 — a smart dash from a comment) which caused:
UnicodeDecodeError: utf-8 codec can't decode byte 0x97
Fix: move the route verification logic to scripts/verify_routes.py
which uses open(..., encoding='utf-8') explicitly, and call it from
test.yml as a single clean line: python3 scripts/verify_routes.py
- .github/workflows/test.yml +2 -14
- scripts/verify_routes.py +24 -0
.github/workflows/test.yml
CHANGED
|
@@ -43,22 +43,10 @@ jobs:
|
|
| 43 |
- name: verify no bolt://localhost in codebase
|
| 44 |
run: |
|
| 45 |
if grep -r "bolt://localhost" --include="*.py" .; then
|
| 46 |
-
echo "ERROR: bolt://localhost found
|
| 47 |
exit 1
|
| 48 |
fi
|
| 49 |
echo "PASS: No bolt://localhost references"
|
| 50 |
|
| 51 |
- name: verify all registered API routes exist
|
| 52 |
-
run:
|
| 53 |
-
python3 -c "
|
| 54 |
-
import re, os, sys
|
| 55 |
-
main = open('api/main.py').read()
|
| 56 |
-
m = re.findall(r'from api\.routes import (.*)', main)
|
| 57 |
-
if m:
|
| 58 |
-
mods = [x.strip() for x in m[0].split(',')]
|
| 59 |
-
missing = [x for x in mods if not os.path.exists(f'api/routes/{x}.py')]
|
| 60 |
-
if missing:
|
| 61 |
-
print('MISSING ROUTE FILES:', missing)
|
| 62 |
-
sys.exit(1)
|
| 63 |
-
print(f'PASS: All {len(mods)} route files present')
|
| 64 |
-
"
|
|
|
|
| 43 |
- name: verify no bolt://localhost in codebase
|
| 44 |
run: |
|
| 45 |
if grep -r "bolt://localhost" --include="*.py" .; then
|
| 46 |
+
echo "ERROR: bolt://localhost found"
|
| 47 |
exit 1
|
| 48 |
fi
|
| 49 |
echo "PASS: No bolt://localhost references"
|
| 50 |
|
| 51 |
- name: verify all registered API routes exist
|
| 52 |
+
run: python3 scripts/verify_routes.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts/verify_routes.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import re, os, sys
|
| 3 |
+
|
| 4 |
+
def verify_routes():
|
| 5 |
+
try:
|
| 6 |
+
with open('api/main.py', 'r', encoding='utf-8') as f:
|
| 7 |
+
main = f.read()
|
| 8 |
+
except FileNotFoundError:
|
| 9 |
+
print("ERROR: api/main.py not found")
|
| 10 |
+
sys.exit(1)
|
| 11 |
+
|
| 12 |
+
m = re.findall(r'from api\.routes import (.*)', main)
|
| 13 |
+
if m:
|
| 14 |
+
mods = [x.strip() for x in m[0].split(',')]
|
| 15 |
+
missing = [x for x in mods if not os.path.exists(f'api/routes/{x}.py')]
|
| 16 |
+
if missing:
|
| 17 |
+
print('MISSING ROUTE FILES:', missing)
|
| 18 |
+
sys.exit(1)
|
| 19 |
+
print(f'PASS: All {len(mods)} route files present')
|
| 20 |
+
else:
|
| 21 |
+
print('PASS: No route imports to check')
|
| 22 |
+
|
| 23 |
+
if __name__ == '__main__':
|
| 24 |
+
verify_routes()
|