Some checks failed
CI/CD Pipeline / Backend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Frontend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Build Backend (push) Has been cancelled
CI/CD Pipeline / Build Frontend (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Performance Tests (push) Has been cancelled
CI/CD Pipeline / Dependency Updates (push) Has been cancelled
- Updated Anthropic API to latest version (2024-01-01) - Set Claude 3.7 Sonnet Latest as primary model - Removed deprecated Opus 3.5 references - Fixed LLM response validation and JSON parsing - Improved error handling and logging - Updated model configurations and pricing - Enhanced document processing reliability - Fixed TypeScript type issues - Updated environment configuration
242 lines
7.4 KiB
Bash
Executable File
242 lines
7.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 🧪 **Firebase Testing Environment Deployment Script**
|
|
# Deploys the CIM Document Processor with Week 8 features to testing environment
|
|
|
|
set -e # Exit on any error
|
|
|
|
echo "🚀 Starting Firebase Testing Environment Deployment..."
|
|
echo "📅 Deployment Date: $(date)"
|
|
echo "🔧 Week 8 Features: Cost Monitoring, Caching, Microservice"
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Function to print colored output
|
|
print_status() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Configuration
|
|
TESTING_PROJECT_ID="cim-summarizer-testing"
|
|
BACKEND_DIR="backend"
|
|
FRONTEND_DIR="frontend"
|
|
|
|
print_status "Configuration:"
|
|
echo " - Testing Project ID: $TESTING_PROJECT_ID"
|
|
echo " - Backend Directory: $BACKEND_DIR"
|
|
echo " - Frontend Directory: $FRONTEND_DIR"
|
|
|
|
# Check if we're in the right directory
|
|
if [ ! -f "IMPROVEMENT_ROADMAP.md" ]; then
|
|
print_error "Please run this script from the project root directory"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if Firebase CLI is installed
|
|
if ! command -v firebase &> /dev/null; then
|
|
print_error "Firebase CLI is not installed. Please install it first:"
|
|
echo " npm install -g firebase-tools"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if we're logged into Firebase
|
|
if ! firebase projects:list &> /dev/null; then
|
|
print_error "Not logged into Firebase. Please login first:"
|
|
echo " firebase login"
|
|
exit 1
|
|
fi
|
|
|
|
print_status "Step 1: Setting up Firebase project..."
|
|
|
|
# Switch to testing project (must be run from backend directory)
|
|
cd $BACKEND_DIR
|
|
if firebase use testing &> /dev/null; then
|
|
print_success "Switched to testing project: $TESTING_PROJECT_ID"
|
|
else
|
|
print_error "Failed to switch to testing project. Please ensure the project exists:"
|
|
echo " firebase projects:list"
|
|
echo " firebase use testing"
|
|
exit 1
|
|
fi
|
|
cd ..
|
|
|
|
print_status "Step 2: Installing dependencies..."
|
|
|
|
# Install backend dependencies
|
|
print_status "Installing backend dependencies..."
|
|
cd $BACKEND_DIR
|
|
npm install
|
|
print_success "Backend dependencies installed"
|
|
|
|
# Install frontend dependencies
|
|
print_status "Installing frontend dependencies..."
|
|
cd ../$FRONTEND_DIR
|
|
npm install
|
|
print_success "Frontend dependencies installed"
|
|
|
|
cd ..
|
|
|
|
print_status "Step 3: Building frontend..."
|
|
|
|
# Build frontend for testing
|
|
cd $FRONTEND_DIR
|
|
npm run build
|
|
print_success "Frontend built successfully"
|
|
|
|
cd ..
|
|
|
|
print_status "Step 4: Building backend..."
|
|
|
|
# Build backend
|
|
cd $BACKEND_DIR
|
|
npm run build
|
|
print_success "Backend built successfully"
|
|
|
|
cd ..
|
|
|
|
print_status "Step 5: Running database migrations..."
|
|
|
|
# Run database migrations for testing environment
|
|
cd $BACKEND_DIR
|
|
|
|
# Check if environment file exists (using main .env which is configured for testing)
|
|
if [ ! -f ".env" ]; then
|
|
print_warning "Environment file (.env) not found"
|
|
print_status "Please ensure .env file exists and is configured for testing"
|
|
exit 1
|
|
fi
|
|
|
|
# Set environment to testing
|
|
export NODE_ENV=testing
|
|
|
|
# Skip migrations since database is already set up
|
|
print_status "Skipping database migrations..."
|
|
print_warning "Database schema already set up manually - skipping migrations"
|
|
print_success "Database setup completed"
|
|
|
|
cd ..
|
|
|
|
print_status "Step 6: Deploying to Firebase..."
|
|
|
|
# Deploy Firebase Functions (from backend directory)
|
|
print_status "Deploying Firebase Functions..."
|
|
cd $BACKEND_DIR
|
|
firebase deploy --only functions --project $TESTING_PROJECT_ID
|
|
print_success "Firebase Functions deployed"
|
|
cd ..
|
|
|
|
# Deploy Firebase Hosting (from frontend directory)
|
|
print_status "Deploying Firebase Hosting..."
|
|
cd $FRONTEND_DIR
|
|
firebase deploy --only hosting --project $TESTING_PROJECT_ID
|
|
print_success "Firebase Hosting deployed"
|
|
cd ..
|
|
|
|
# Skip Firebase Storage rules (no rules file defined)
|
|
print_status "Skipping Firebase Storage rules..."
|
|
print_warning "No storage.rules file found - skipping storage deployment"
|
|
print_success "Storage rules deployment skipped"
|
|
|
|
print_status "Step 7: Verifying deployment..."
|
|
|
|
# Test the deployment
|
|
print_status "Testing API endpoints..."
|
|
|
|
# Get the deployed URL
|
|
DEPLOYED_URL=$(firebase hosting:channel:list --project $TESTING_PROJECT_ID | grep "live" | awk '{print $2}' || echo "https://$TESTING_PROJECT_ID.web.app")
|
|
|
|
print_status "Testing health endpoint..."
|
|
HEALTH_RESPONSE=$(curl -s "$DEPLOYED_URL/health" || echo "Failed to connect")
|
|
|
|
if [[ $HEALTH_RESPONSE == *"healthy"* ]]; then
|
|
print_success "Health endpoint is working"
|
|
else
|
|
print_warning "Health endpoint test failed: $HEALTH_RESPONSE"
|
|
fi
|
|
|
|
print_status "Step 8: Week 8 Features Verification..."
|
|
|
|
# Test new Week 8 endpoints
|
|
print_status "Testing cost monitoring endpoints..."
|
|
COST_RESPONSE=$(curl -s "$DEPLOYED_URL/api/cost/user-metrics" || echo "Failed to connect")
|
|
|
|
if [[ $COST_RESPONSE == *"error"* ]] && [[ $COST_RESPONSE == *"not authenticated"* ]]; then
|
|
print_success "Cost monitoring endpoint is working (authentication required)"
|
|
else
|
|
print_warning "Cost monitoring endpoint test: $COST_RESPONSE"
|
|
fi
|
|
|
|
print_status "Testing cache management endpoints..."
|
|
CACHE_RESPONSE=$(curl -s "$DEPLOYED_URL/api/cache/stats" || echo "Failed to connect")
|
|
|
|
if [[ $CACHE_RESPONSE == *"error"* ]] && [[ $CACHE_RESPONSE == *"not authenticated"* ]]; then
|
|
print_success "Cache management endpoint is working (authentication required)"
|
|
else
|
|
print_warning "Cache management endpoint test: $CACHE_RESPONSE"
|
|
fi
|
|
|
|
print_status "Testing microservice endpoints..."
|
|
MICROSERVICE_RESPONSE=$(curl -s "$DEPLOYED_URL/api/processing/health" || echo "Failed to connect")
|
|
|
|
if [[ $MICROSERVICE_RESPONSE == *"error"* ]] && [[ $MICROSERVICE_RESPONSE == *"not authenticated"* ]]; then
|
|
print_success "Microservice endpoint is working (authentication required)"
|
|
else
|
|
print_warning "Microservice endpoint test: $MICROSERVICE_RESPONSE"
|
|
fi
|
|
|
|
print_status "Step 9: Environment Configuration..."
|
|
|
|
# Display deployment information
|
|
echo ""
|
|
print_success "🎉 Deployment to Firebase Testing Environment Complete!"
|
|
echo ""
|
|
echo "📋 Deployment Summary:"
|
|
echo " - Project ID: $TESTING_PROJECT_ID"
|
|
echo " - Frontend URL: https://$TESTING_PROJECT_ID.web.app"
|
|
echo " - API Base URL: https://$TESTING_PROJECT_ID.web.app"
|
|
echo ""
|
|
echo "🔧 Week 8 Features Deployed:"
|
|
echo " ✅ Document Analysis Caching System"
|
|
echo " ✅ Real-time Cost Monitoring"
|
|
echo " ✅ Document Processing Microservice"
|
|
echo " ✅ New API Endpoints (/api/cost, /api/cache, /api/processing)"
|
|
echo " ✅ Database Schema Updates"
|
|
echo ""
|
|
echo "🧪 Testing Instructions:"
|
|
echo " 1. Visit: https://$TESTING_PROJECT_ID.web.app"
|
|
echo " 2. Create a test account"
|
|
echo " 3. Upload test documents"
|
|
echo " 4. Monitor cost tracking in real-time"
|
|
echo " 5. Test cache functionality with similar documents"
|
|
echo " 6. Check microservice health and queue status"
|
|
echo ""
|
|
echo "📊 Monitoring:"
|
|
echo " - Firebase Console: https://console.firebase.google.com/project/$TESTING_PROJECT_ID"
|
|
echo " - Functions Logs: firebase functions:log --project $TESTING_PROJECT_ID"
|
|
echo " - Hosting Analytics: Available in Firebase Console"
|
|
echo ""
|
|
echo "🔍 Troubleshooting:"
|
|
echo " - Check logs: firebase functions:log --project $TESTING_PROJECT_ID"
|
|
echo " - View functions: firebase functions:list --project $TESTING_PROJECT_ID"
|
|
echo " - Test locally: firebase emulators:start --project $TESTING_PROJECT_ID"
|
|
echo ""
|
|
|
|
print_success "Deployment completed successfully! 🚀"
|