name: BlackRoad OS CI on: push: branches: [ "main" ] pull_request: branches: [ "main" ] workflow_dispatch: jobs: validate: name: Validate HTML & JavaScript runs-on: ubuntu-latest env: UI_ENTRY: backend/static/index.html steps: - name: Checkout repository uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 with: python-version: '3.11' - name: Validate HTML structure run: | echo "š Validating HTML structure..." python3 << 'EOF' import os import sys import re def validate_html(filename): errors = [] warnings = [] try: with open(filename, 'r') as f: content = f.read() except FileNotFoundError: print(f"ā¹ļø No {filename} found - skipping validation") return True # Check basic structure if not content.strip().startswith(''): errors.append("Missing DOCTYPE declaration") if '' not in content: errors.append("Missing html tags") if '
' not in content or '' not in content: errors.append("Missing head tags") if '' not in content or '' not in content: errors.append("Missing body tags") # Check for unclosed tags script_opens = content.count('', content, re.DOTALL) if not script_match: print("ā¹ļø No inline JavaScript found") sys.exit(0) js_code = script_match.group(1) # Basic syntax checks issues = [] # Check for common syntax errors if js_code.count('{') != js_code.count('}'): issues.append(f"Mismatched braces: {js_code.count('{')} opens, {js_code.count('}')} closes") if js_code.count('(') != js_code.count(')'): issues.append(f"Mismatched parentheses: {js_code.count('(')} opens, {js_code.count(')')} closes") if js_code.count('[') != js_code.count(']'): issues.append(f"Mismatched brackets: {js_code.count('[')} opens, {js_code.count(']')} closes") # Check for basic structure functions = len(re.findall(r'function\s+\w+', js_code)) print(f"\n{'='*60}") print(f"JavaScript Syntax Check") print(f"{'='*60}") print(f"Code size: {len(js_code):,} bytes") print(f"Functions declared: {functions}") print(f"Braces: {js_code.count('{')} matched pairs") print(f"Parentheses: {js_code.count('(')} matched pairs") print(f"Brackets: {js_code.count('[')} matched pairs") if issues: print(f"\nā SYNTAX ISSUES ({len(issues)}):") for i, issue in enumerate(issues, 1): print(f" {i}. {issue}") sys.exit(1) else: print("\nā JavaScript syntax appears valid!") sys.exit(0) EOF else echo "ā¹ļø No UI entrypoint found - skipping JS validation" fi - name: Check for common security issues run: | echo "š Checking for security issues..." if [ -f "$UI_ENTRY" ]; then # Check for inline event handlers with user input (basic XSS check) if grep -i "eval(" "$UI_ENTRY"; then echo "ā ļø Warning: Found eval() - potential security risk" # Not failing for this, just warning fi if grep -i "innerHTML.*user" "$UI_ENTRY"; then echo "ā ļø Warning: Found innerHTML with user input - potential XSS risk" fi echo "ā Basic security checks completed" else echo "ā¹ļø No UI entrypoint found - skipping security checks" fi - name: Validate README run: | echo "š Checking README..." if [ -f "README.md" ]; then word_count=$(wc -w < README.md) line_count=$(wc -l < README.md) echo "README.md: $line_count lines, $word_count words" if [ $word_count -lt 50 ]; then echo "ā ļø README is quite short (< 50 words)" else echo "ā README is comprehensive" fi else echo "ā No README.md found!" exit 1 fi - name: Summary if: success() run: | echo "" echo "āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā" echo "ā ā" echo "ā ā All BlackRoad OS validation checks passed! ā" echo "ā ā" echo "ā The code is ready for deployment to GitHub Pages. ā" echo "ā ā" echo "āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā" echo ""