name: Quick Integration Test
on:
workflow_dispatch:
inputs:
sync_days:
description: 'Days of history to sync (default: 1)'
required: false
default: '1'
type: string
push:
branches: [main]
pull_request:
branches: [main]
env:
PYTHONPATH: ${{ github.workspace }}
FORCE_COLOR: 1
jobs:
quick-integration-test:
name: Quick API Integration Test
runs-on: ubuntu-latest
timeout-minutes: 10 # Much shorter timeout for quick test
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y sqlite3
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest pytest-asyncio pytest-cov httpx[http2]
- name: Verify package installation
run: |
python -c "import fast_intercom_mcp; print(f'✅ Package imported successfully')"
python -m fast_intercom_mcp --help
- name: Create test environment
run: |
mkdir -p quick_test_data
cd quick_test_data
echo "✅ Quick test environment created"
- name: Run quick integration test
working-directory: quick_test_data
env:
INTERCOM_ACCESS_TOKEN: ${{ secrets.INTERCOM_ACCESS_TOKEN }}
run: |
set -e
echo "🚀 Starting Quick Integration Test"
echo "Test environment: $(python --version)"
echo "Sync days: ${{ github.event.inputs.sync_days || '1' }}"
echo "Expected duration: 3-5 minutes"
echo ""
# Quick test with minimal data
SYNC_DAYS=${{ github.event.inputs.sync_days || '1' }}
python -c "
import asyncio
import os
import json
import time
from datetime import datetime, timedelta, UTC
from fast_intercom_mcp.sync_service import SyncService
from fast_intercom_mcp.database import DatabaseManager
from fast_intercom_mcp.intercom_client import IntercomClient
async def run_quick_test():
print('⏱️ Test started at:', datetime.now(UTC).strftime('%H:%M:%S UTC'))
# Initialize components
db = DatabaseManager('./quick_test.db')
client = IntercomClient(os.getenv('INTERCOM_ACCESS_TOKEN'))
sync_service = SyncService(db, client)
# Quick API connection test
print('🔌 Testing API connection...')
connection_result = await client.test_connection()
if not connection_result:
raise Exception('API connection failed')
print('✅ API connection successful')
# Quick sync test with limited conversations for speed
sync_days = int('$SYNC_DAYS')
end_date = datetime.now(UTC)
start_date = end_date - timedelta(days=sync_days)
print(f'🔄 Quick sync: {sync_days} day(s) of data (limited to 50 conversations for speed)')
print(f'📅 Period: {start_date.strftime(\"%Y-%m-%d\")} to {end_date.strftime(\"%Y-%m-%d\")}')
sync_start = time.time()
# Use the proven sync_period method with a very short period for speed
recent_time = end_date - timedelta(hours=2) # Last 2 hours for speed
print(f'🔄 Using sync_period with last 2 hours: {recent_time.strftime(\"%H:%M\")} to {end_date.strftime(\"%H:%M\")}')
stats = await sync_service.sync_period(recent_time, end_date)
sync_duration = time.time() - sync_start
# Results
rate = stats.total_conversations / max(sync_duration, 1)
print('')
print('📊 Quick Test Results:')
print(f'✅ Conversations synced: {stats.total_conversations:,}')
print(f'✅ Messages synced: {stats.total_messages:,}')
print(f'✅ Sync speed: {rate:.1f} conversations/second')
print(f'✅ Duration: {sync_duration:.1f} seconds')
print(f'✅ API calls: {stats.api_calls_made:,}')
# Quick MCP tool test
print('')
print('🛠️ Testing MCP tools...')
status = sync_service.get_status()
print(f'✅ Sync service status: OK')
# Save quick results
quick_results = {
'test_type': 'quick',
'sync_days': sync_days,
'conversations': stats.total_conversations,
'messages': stats.total_messages,
'duration_seconds': round(sync_duration, 2),
'rate_conv_per_sec': round(rate, 2),
'api_calls': stats.api_calls_made,
'timestamp': datetime.now(UTC).isoformat()
}
with open('quick_results.json', 'w') as f:
json.dump(quick_results, f, indent=2)
print('')
print('🎉 Quick integration test PASSED!')
print(f'⏱️ Completed at: {datetime.now(UTC).strftime(\"%H:%M:%S UTC\")}')
return True
# Run the test
success = asyncio.run(run_quick_test())
if not success:
exit(1)
"
- name: Upload quick test results
if: always()
uses: actions/upload-artifact@v4
with:
name: quick-test-results-${{ github.run_id }}
path: |
quick_test_data/quick_results.json
quick_test_data/quick_test.db
retention-days: 7
- name: Display quick test summary
if: always()
working-directory: quick_test_data
run: |
echo ""
echo "📋 QUICK TEST SUMMARY"
echo "===================="
if [ -f quick_results.json ]; then
echo "✅ Status: SUCCESS"
echo "📊 Results:"
cat quick_results.json | python -m json.tool
else
echo "❌ Status: FAILED"
echo "Check logs above for error details"
fi