#!/bin/bash # File: /home/oib/windsurf/aitbc/scripts/check-documentation-requirements.sh set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo "šŸ” Checking Documentation for Requirement Consistency" echo "==================================================" ISSUES_FOUND=false # Function to check Python version in documentation check_python_docs() { echo -e "\nšŸ“‹ Checking Python version documentation..." # Find all markdown files find docs/ -name "*.md" -type f | while read -r file; do # Check for incorrect Python versions if grep -q "python.*3\.[0-9][0-9]" "$file"; then echo -e "${YELLOW}āš ļø $file: Contains Python version references${NC}" grep -n "python.*3\.[0-9][0-9]" "$file" | head -3 fi # Check for correct Python 3.13.5 requirement if grep -q "3\.13\.5" "$file"; then echo -e "${GREEN}āœ… $file: Contains Python 3.13.5 requirement${NC}" fi done } # Function to check system requirements documentation check_system_docs() { echo -e "\nšŸ“‹ Checking system requirements documentation..." # Check main deployment guide if [ -f "docs/10_plan/aitbc.md" ]; then echo "Checking aitbc.md..." # Check Python version if grep -q "3\.13\.5.*minimum.*requirement" docs/10_plan/aitbc.md; then echo -e "${GREEN}āœ… Python 3.13.5 minimum requirement documented${NC}" else echo -e "${RED}āŒ Python 3.13.5 minimum requirement missing or incorrect${NC}" ISSUES_FOUND=true fi # Check system requirements if grep -q "8GB.*RAM.*minimum" docs/10_plan/aitbc.md; then echo -e "${GREEN}āœ… Memory requirement documented${NC}" else echo -e "${RED}āŒ Memory requirement missing or incorrect${NC}" ISSUES_FOUND=true fi # Check storage requirement if grep -q "50GB.*available.*space" docs/10_plan/aitbc.md; then echo -e "${GREEN}āœ… Storage requirement documented${NC}" else echo -e "${RED}āŒ Storage requirement missing or incorrect${NC}" ISSUES_FOUND=true fi else echo -e "${RED}āŒ Main deployment guide (aitbc.md) not found${NC}" ISSUES_FOUND=true fi } # Function to check service files for Python version checks check_service_files() { echo -e "\nšŸ“‹ Checking service files for Python version validation..." if [ -d "systemd" ]; then find systemd/ -name "*.service" -type f | while read -r file; do if grep -q "python.*version" "$file"; then echo -e "${GREEN}āœ… $file: Contains Python version check${NC}" else echo -e "${YELLOW}āš ļø $file: Missing Python version check${NC}" fi done fi } # Function to check requirements files check_requirements_files() { echo -e "\nšŸ“‹ Checking requirements files..." # Check Python requirements if [ -f "apps/coordinator-api/requirements.txt" ]; then echo "Checking coordinator-api requirements.txt..." # Check for Python version specification if grep -q "python_requires" apps/coordinator-api/requirements.txt; then echo -e "${GREEN}āœ… Python version requirement specified${NC}" else echo -e "${YELLOW}āš ļø Python version requirement not specified in requirements.txt${NC}" fi fi # Check pyproject.toml if [ -f "pyproject.toml" ]; then echo "Checking pyproject.toml..." if grep -q "requires-python.*3\.13" pyproject.toml; then echo -e "${GREEN}āœ… Python 3.13+ requirement in pyproject.toml${NC}" else echo -e "${YELLOW}āš ļø Python 3.13+ requirement missing in pyproject.toml${NC}" fi fi } # Function to check for hardcoded versions in code check_hardcoded_versions() { echo -e "\nšŸ“‹ Checking for hardcoded versions in code..." # Find Python files with version checks find apps/ -name "*.py" -type f -exec grep -l "sys.version_info" {} \; | while read -r file; do echo -e "${GREEN}āœ… $file: Contains version check${NC}" # Check if version is correct if grep -q "3.*13.*5" "$file"; then echo -e "${GREEN} āœ… Correct version requirement (3.13.5)${NC}" else echo -e "${YELLOW} āš ļø May have incorrect version requirement${NC}" fi done } # Run all checks check_python_docs check_system_docs check_service_files check_requirements_files check_hardcoded_versions # Summary echo -e "\nšŸ“Š Documentation Check Summary" echo "=============================" if [ "$ISSUES_FOUND" = true ]; then echo -e "${RED}āŒ Issues found in documentation requirements${NC}" echo -e "${RED}Please fix the above issues before deployment${NC}" exit 1 else echo -e "${GREEN}āœ… Documentation requirements are consistent${NC}" echo -e "${GREEN}Ready for deployment!${NC}" exit 0 fi