#!/bin/bash # Renovate Configuration Validator # This script validates the renovate.json configuration and checks for common issues set -e echo "🔍 Renovate Configuration Validator" echo "==================================" # Check if renovate.json exists if [ ! -f "renovate.json" ]; then echo "❌ renovate.json not found in current directory" exit 1 fi echo "✓ Found renovate.json" # Check if Node.js is available if ! command -v node &> /dev/null; then echo "âš ī¸ Node.js not found, installing..." # For Ubuntu/Debian systems if command -v apt-get &> /dev/null; then curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt-get install -y nodejs else echo "❌ Please install Node.js 18+ to validate configuration" exit 1 fi fi # Install renovate CLI if not present if ! command -v renovate &> /dev/null; then echo "đŸ“Ļ Installing Renovate CLI..." # Check Node.js version and install compatible Renovate version NODE_VERSION=$(node --version | cut -d'v' -f2) if [[ $(echo "$NODE_VERSION 24.10.0" | awk '{print ($1 >= $2)}') == 1 ]]; then echo "Installing latest Renovate for Node.js $NODE_VERSION" npm install -g renovate@latest else echo "Installing compatible Renovate version for Node.js $NODE_VERSION" npm install -g renovate@40.3.2 fi fi echo "✓ Renovate CLI available" # Validate configuration syntax echo "" echo "🔧 Validating renovate.json syntax..." # First, validate JSON syntax if ! node -e " try { const config = JSON.parse(require('fs').readFileSync('renovate.json', 'utf8')); console.log('✓ JSON syntax is valid'); console.log('✓ Configuration has', Object.keys(config).length, 'top-level properties'); } catch(e) { console.error('❌ JSON syntax error:', e.message); process.exit(1); }"; then exit 1 fi # Then, test Renovate can parse the config (basic validation) echo "🔍 Testing Renovate configuration parsing..." if timeout 30 renovate --dry-run --log-level=warn . 2>&1 | grep -qi "error\|fatal"; then echo "âš ī¸ Renovate reported warnings/errors during config parsing" echo "â„šī¸ Run 'renovate --dry-run --log-level=debug .' for detailed analysis" echo "â„šī¸ This may be normal for first-time setup" else echo "✓ Renovate configuration parsing completed" fi # Check for required package files echo "" echo "📋 Checking for supported package managers..." PACKAGE_FILES_FOUND=0 # Python (uv/pip) if [ -f "backend/pyproject.toml" ]; then echo "✓ Python: backend/pyproject.toml" PACKAGE_FILES_FOUND=$((PACKAGE_FILES_FOUND + 1)) fi # Node.js (npm/yarn) if [ -f "frontend/package.json" ]; then echo "✓ Node.js: frontend/package.json" PACKAGE_FILES_FOUND=$((PACKAGE_FILES_FOUND + 1)) fi # Docker DOCKERFILE_COUNT=$(find . -name "Dockerfile*" -type f | wc -l) if [ $DOCKERFILE_COUNT -gt 0 ]; then echo "✓ Docker: $DOCKERFILE_COUNT Dockerfile(s) found" PACKAGE_FILES_FOUND=$((PACKAGE_FILES_FOUND + 1)) fi # GitHub Actions (if any) WORKFLOW_COUNT=$(find .gitea/workflows -name "*.yml" -o -name "*.yaml" 2>/dev/null | wc -l) if [ $WORKFLOW_COUNT -gt 0 ]; then echo "✓ Gitea Actions: $WORKFLOW_COUNT workflow(s) found" fi if [ $PACKAGE_FILES_FOUND -eq 0 ]; then echo "âš ī¸ No supported package files found" echo " Renovate looks for: pyproject.toml, package.json, Dockerfile, etc." else echo "✓ Found $PACKAGE_FILES_FOUND package manager types" fi # Validate common configuration issues echo "" echo "🔍 Checking configuration best practices..." # Check for timezone setting if grep -q "timezone" renovate.json; then echo "✓ Timezone configured" else echo "â„šī¸ Consider adding timezone setting for consistent scheduling" fi # Check for schedule configuration if grep -q "schedule" renovate.json; then echo "✓ Update schedule configured" else echo "â„šī¸ Consider adding schedule to control when updates run" fi # Check for automerge rules if grep -q "automerge" renovate.json; then echo "✓ Automerge rules configured" else echo "â„šī¸ Consider configuring automerge for safe updates" fi # Check for vulnerability alerts if grep -q "vulnerabilityAlerts\|osvVulnerabilityAlerts" renovate.json; then echo "✓ Security vulnerability alerts enabled" else echo "âš ī¸ Consider enabling vulnerability alerts for security updates" fi echo "" echo "🚀 Next Steps for Gitea Setup:" echo "1. Create a Gitea API token with repository access" echo "2. Add the token as RENOVATE_TOKEN in repository secrets" echo "3. Enable the renovate.yml workflow in Gitea Actions" echo "4. Test with manual workflow trigger (dry-run mode)" echo "" echo "📚 Documentation: docs/RENOVATE_SETUP_GUIDE.md" echo "" echo "✅ Configuration validation complete!"