Skip to content

Commit d9e5ff8

Browse files
authored
Merge branch 'main' into wegent/feature-custom-shell-base-image
2 parents ffbaf5b + bcec0fa commit d9e5ff8

File tree

1 file changed

+76
-64
lines changed

1 file changed

+76
-64
lines changed

scripts/hooks/ai-push-gate.sh

Lines changed: 76 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,9 @@ if [ "$FRONTEND_COUNT" -gt 0 ] 2>/dev/null; then
182182

183183
# Check if we're in the right directory and node_modules exists
184184
if [ ! -d "frontend/node_modules" ]; then
185-
echo -e " ${RED}❌ FAILED: node_modules not found${NC}"
186-
echo -e " ${RED} Run 'cd frontend && npm install' to install dependencies${NC}"
187-
echo -e " ${YELLOW}⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks.${NC}"
188-
CHECK_FAILED=1
189-
FAILED_CHECKS+=("Frontend Dependencies")
190-
FAILED_LOGS+=("=== Frontend Dependencies Missing ===
191-
node_modules directory not found in frontend/
192-
Fix: cd frontend && npm install
193-
⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks.")
185+
echo -e " ${YELLOW}⚠️ SKIP: node_modules not found${NC}"
186+
echo -e " ${YELLOW} Run 'cd frontend && npm install' to install dependencies${NC}"
187+
WARNINGS+=("Frontend: node_modules not found, checks skipped")
194188
else
195189
cd frontend
196190

@@ -251,18 +245,63 @@ if [ "$BACKEND_COUNT" -gt 0 ] 2>/dev/null; then
251245

252246
# Check if virtual environment or Python packages are available
253247
if ! command -v black &> /dev/null && [ ! -f "venv/bin/black" ]; then
254-
echo -e " ${RED}❌ FAILED: black not found${NC}"
255-
echo -e " ${RED} Run 'pip install black isort pytest' to install dependencies${NC}"
256-
echo -e " ${YELLOW}⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks.${NC}"
257-
CHECK_FAILED=1
258-
FAILED_CHECKS+=("Backend Dependencies (black)")
259-
FAILED_LOGS+=("=== Backend Dependencies Missing ===
260-
black command not found
261-
Fix: pip install black isort pytest
262-
⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks.")
248+
echo -e " ${YELLOW}⚠️ SKIP: black not found${NC}"
249+
echo -e " ${YELLOW} Run 'pip install black isort pytest' to install dependencies${NC}"
250+
WARNINGS+=("Backend: black not found, format checks skipped")
251+
252+
# Still try to run other checks if available
253+
# isort check
254+
if ! command -v isort &> /dev/null; then
255+
echo -e " ${YELLOW}⚠️ SKIP: isort not found${NC}"
256+
WARNINGS+=("Backend: isort not found, import sort checks skipped")
257+
fi
258+
259+
# pytest
260+
if ! command -v pytest &> /dev/null; then
261+
echo -e " ${YELLOW}⚠️ SKIP: pytest not found${NC}"
262+
WARNINGS+=("Backend: pytest not found, tests skipped")
263+
else
264+
echo -e " Running pytest..."
265+
if [ -d "tests" ]; then
266+
pytest tests/ --tb=short -q > "$TEMP_DIR/backend_pytest.log" 2>&1
267+
PYTEST_EXIT=$?
268+
if [ $PYTEST_EXIT -eq 0 ]; then
269+
echo -e " ${GREEN}✅ Pytest: PASSED${NC}"
270+
else
271+
echo -e " ${RED}❌ Pytest: FAILED${NC}"
272+
CHECK_FAILED=1
273+
FAILED_CHECKS+=("Backend Pytest")
274+
FAILED_LOGS+=("$TEMP_DIR/backend_pytest.log")
275+
fi
276+
else
277+
echo -e " ${YELLOW}⚠️ SKIP: tests directory not found${NC}"
278+
WARNINGS+=("Backend: tests directory not found")
279+
fi
280+
fi
281+
282+
# Python syntax check
283+
echo -e " Running Python syntax check..."
284+
SYNTAX_ERROR=0
285+
> "$TEMP_DIR/syntax.log" # Clear/create the file
286+
for pyfile in $(echo "$CHANGED_FILES" | grep "^backend/.*\.py$"); do
287+
if [ -f "../$pyfile" ]; then
288+
python -m py_compile "../$pyfile" 2>> "$TEMP_DIR/syntax.log"
289+
if [ $? -ne 0 ]; then
290+
echo -e " ${RED} Syntax error in: $pyfile${NC}"
291+
SYNTAX_ERROR=1
292+
fi
293+
fi
294+
done
295+
if [ $SYNTAX_ERROR -eq 0 ]; then
296+
echo -e " ${GREEN}✅ Syntax Check: PASSED${NC}"
297+
else
298+
echo -e " ${RED}❌ Syntax Check: FAILED${NC}"
299+
CHECK_FAILED=1
300+
FAILED_CHECKS+=("Backend Syntax")
301+
FAILED_LOGS+=("$TEMP_DIR/syntax.log")
302+
fi
263303
cd ..
264304
else
265-
# Black format check
266305
# Black format check (output to temp file)
267306
echo -e " Running Black format check..."
268307
black --check app/ > "$TEMP_DIR/black.log" 2>&1
@@ -280,15 +319,10 @@ Fix: pip install black isort pytest
280319

281320
# isort check
282321
if ! command -v isort &> /dev/null; then
283-
echo -e " ${RED}❌ FAILED: isort not found${NC}"
284-
echo -e " ${RED} Run 'pip install isort' to install dependencies${NC}"
285-
echo -e " ${YELLOW}⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks.${NC}"
286-
CHECK_FAILED=1
287-
FAILED_CHECKS+=("Backend Dependencies (isort)")
288-
echo -e "=== Backend Dependencies Missing ===\nisort command not found\nFix: pip install isort\n⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks." > "$TEMP_DIR/isort_missing.log"
289-
FAILED_LOGS+=("$TEMP_DIR/isort_missing.log")
322+
echo -e " ${YELLOW}⚠️ SKIP: isort not found${NC}"
323+
echo -e " ${YELLOW} Run 'pip install isort' to install dependencies${NC}"
324+
WARNINGS+=("Backend: isort not found, import sort checks skipped")
290325
else
291-
echo -e " Running isort check..."
292326
isort --check-only --diff app/ > "$TEMP_DIR/isort.log" 2>&1
293327
ISORT_EXIT=$?
294328
if [ $ISORT_EXIT -eq 0 ]; then
@@ -304,13 +338,9 @@ Fix: pip install black isort pytest
304338

305339
# pytest
306340
if ! command -v pytest &> /dev/null; then
307-
echo -e " ${RED}❌ FAILED: pytest not found${NC}"
308-
echo -e " ${RED} Run 'pip install pytest' to install dependencies${NC}"
309-
echo -e " ${YELLOW}⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks.${NC}"
310-
CHECK_FAILED=1
311-
FAILED_CHECKS+=("Backend Dependencies (pytest)")
312-
echo -e "=== Backend Dependencies Missing ===\npytest command not found\nFix: pip install pytest\n⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks." > "$TEMP_DIR/pytest_missing.log"
313-
FAILED_LOGS+=("$TEMP_DIR/pytest_missing.log")
341+
echo -e " ${YELLOW}⚠️ SKIP: pytest not found${NC}"
342+
echo -e " ${YELLOW} Run 'pip install pytest' to install dependencies${NC}"
343+
WARNINGS+=("Backend: pytest not found, tests skipped")
314344
else
315345
echo -e " Running pytest..."
316346
if [ -d "tests" ]; then
@@ -325,14 +355,10 @@ Fix: pip install black isort pytest
325355
FAILED_LOGS+=("$TEMP_DIR/backend_pytest.log")
326356
fi
327357
else
328-
echo -e " ${RED}❌ FAILED: tests directory not found${NC}"
329-
CHECK_FAILED=1
330-
FAILED_CHECKS+=("Backend Tests Directory")
331-
echo -e "=== Backend Tests Directory Missing ===\ntests/ directory not found in backend/\nFix: Create tests/ directory with test files" > "$TEMP_DIR/backend_tests_missing.log"
332-
FAILED_LOGS+=("$TEMP_DIR/backend_tests_missing.log")
358+
echo -e " ${YELLOW}⚠️ SKIP: tests directory not found${NC}"
359+
WARNINGS+=("Backend: tests directory not found")
333360
fi
334361
fi
335-
# Python syntax check
336362
# Python syntax check (output to temp file)
337363
echo -e " Running Python syntax check..."
338364
SYNTAX_ERROR=0
@@ -368,13 +394,9 @@ if [ "$EXECUTOR_COUNT" -gt 0 ] 2>/dev/null; then
368394
cd executor
369395

370396
if ! command -v pytest &> /dev/null; then
371-
echo -e " ${RED}❌ FAILED: pytest not found${NC}"
372-
echo -e " ${RED} Run 'pip install pytest' to install dependencies${NC}"
373-
echo -e " ${YELLOW}⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks.${NC}"
374-
CHECK_FAILED=1
375-
FAILED_CHECKS+=("Executor Dependencies (pytest)")
376-
echo -e "=== Executor Dependencies Missing ===\npytest command not found\nFix: pip install pytest\n⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks." > "$TEMP_DIR/executor_pytest_missing.log"
377-
FAILED_LOGS+=("$TEMP_DIR/executor_pytest_missing.log")
397+
echo -e " ${YELLOW}⚠️ SKIP: pytest not found${NC}"
398+
echo -e " ${YELLOW} Run 'pip install pytest' to install dependencies${NC}"
399+
WARNINGS+=("Executor: pytest not found, tests skipped")
378400
else
379401
echo -e " Running pytest..."
380402
if [ -d "tests" ]; then
@@ -389,11 +411,8 @@ if [ "$EXECUTOR_COUNT" -gt 0 ] 2>/dev/null; then
389411
FAILED_LOGS+=("$TEMP_DIR/executor_pytest.log")
390412
fi
391413
else
392-
echo -e " ${RED}❌ FAILED: tests directory not found${NC}"
393-
CHECK_FAILED=1
394-
FAILED_CHECKS+=("Executor Tests Directory")
395-
echo -e "=== Executor Tests Directory Missing ===\ntests/ directory not found in executor/\nFix: Create tests/ directory with test files" > "$TEMP_DIR/executor_tests_missing.log"
396-
FAILED_LOGS+=("$TEMP_DIR/executor_tests_missing.log")
414+
echo -e " ${YELLOW}⚠️ SKIP: tests directory not found${NC}"
415+
WARNINGS+=("Executor: tests directory not found")
397416
fi
398417
fi
399418

@@ -409,13 +428,9 @@ if [ "$EXECUTOR_MGR_COUNT" -gt 0 ] 2>/dev/null; then
409428

410429
cd executor_manager
411430
if ! command -v pytest &> /dev/null; then
412-
echo -e " ${RED}❌ FAILED: pytest not found${NC}"
413-
echo -e " ${RED} Run 'pip install pytest' to install dependencies${NC}"
414-
echo -e " ${YELLOW}⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks.${NC}"
415-
CHECK_FAILED=1
416-
FAILED_CHECKS+=("Executor Manager Dependencies (pytest)")
417-
echo -e "=== Executor Manager Dependencies Missing ===\npytest command not found\nFix: pip install pytest\n⚠️ Please install dependencies and re-run 'git push'. Do NOT skip checks." > "$TEMP_DIR/exec_mgr_pytest_missing.log"
418-
FAILED_LOGS+=("$TEMP_DIR/exec_mgr_pytest_missing.log")
431+
echo -e " ${YELLOW}⚠️ SKIP: pytest not found${NC}"
432+
echo -e " ${YELLOW} Run 'pip install pytest' to install dependencies${NC}"
433+
WARNINGS+=("Executor Manager: pytest not found, tests skipped")
419434
else
420435
echo -e " Running pytest..."
421436
if [ -d "tests" ]; then
@@ -433,11 +448,8 @@ if [ "$EXECUTOR_MGR_COUNT" -gt 0 ] 2>/dev/null; then
433448
FAILED_LOGS+=("$TEMP_DIR/exec_mgr_pytest.log")
434449
fi
435450
else
436-
echo -e " ${RED}❌ FAILED: tests directory not found${NC}"
437-
CHECK_FAILED=1
438-
FAILED_CHECKS+=("Executor Manager Tests Directory")
439-
echo -e "=== Executor Manager Tests Directory Missing ===\ntests/ directory not found in executor_manager/\nFix: Create tests/ directory with test files" > "$TEMP_DIR/exec_mgr_tests_missing.log"
440-
FAILED_LOGS+=("$TEMP_DIR/exec_mgr_tests_missing.log")
451+
echo -e " ${YELLOW}⚠️ SKIP: tests directory not found${NC}"
452+
WARNINGS+=("Executor Manager: tests directory not found")
441453
fi
442454
fi
443455

0 commit comments

Comments
 (0)