@@ -40,6 +40,134 @@ jobs:
4040 echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}" >> $GITHUB_ENV
4141 echo "OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}" >> $GITHUB_ENV
4242 echo "OPENAI_MODEL_NAME=${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}" >> $GITHUB_ENV
43+ echo "LOGLEVEL=DEBUG" >> $GITHUB_ENV
44+ echo "PYTHONPATH=${{ github.workspace }}/src/praisonai-agents:$PYTHONPATH" >> $GITHUB_ENV
45+ # Also export to current shell session for immediate availability
46+ export OPENAI_API_KEY="${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}"
47+ export OPENAI_API_BASE="${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}"
48+ export OPENAI_MODEL_NAME="${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}"
49+ export LOGLEVEL=DEBUG
50+ # Verify immediate availability
51+ echo "🔧 Immediate verification in same step:"
52+ echo " OPENAI_API_KEY length in current session: ${#OPENAI_API_KEY}"
53+ echo " OPENAI_API_KEY starts with sk-: $(echo "$OPENAI_API_KEY" | grep -q '^sk-' && echo 'YES' || echo 'NO')"
54+
55+ - name : Debug API Key Status
56+ run : |
57+ echo "🔍 Checking API key availability..."
58+ if [ -n "${{ secrets.OPENAI_API_KEY }}" ]; then
59+ echo "✅ GitHub secret OPENAI_API_KEY is available"
60+ echo "🔑 API key starts with: $(echo "$OPENAI_API_KEY" | cut -c1-7)..."
61+ else
62+ echo "⚠️ GitHub secret OPENAI_API_KEY is NOT set - using fallback"
63+ echo "🔑 Using fallback key: sk-test-key..."
64+ fi
65+ echo "🌐 API Base: $OPENAI_API_BASE"
66+ echo "🤖 Model: $OPENAI_MODEL_NAME"
67+ echo "🐛 Log Level: $LOGLEVEL"
68+ echo "📊 Environment Check:"
69+ echo " - OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
70+ echo " - OPENAI_API_BASE: $OPENAI_API_BASE"
71+ echo " - OPENAI_MODEL_NAME: $OPENAI_MODEL_NAME"
72+ echo " - LOGLEVEL: $LOGLEVEL"
73+ echo "🔍 Is API key actually set?"
74+ echo " - API key starts with sk-: $(echo "$OPENAI_API_KEY" | grep -q '^sk-' && echo 'YES' || echo 'NO')"
75+ echo " - API key is not test key: $([ "$OPENAI_API_KEY" != 'sk-test-key-for-github-actions-testing-only-not-real' ] && echo 'YES' || echo 'NO')"
76+
77+ - name : Debug Environment Variables Raw
78+ run : |
79+ echo "🔧 Raw environment variable check:"
80+ echo "OPENAI_API_KEY set: $(if [ -n "$OPENAI_API_KEY" ]; then echo 'YES'; else echo 'NO'; fi)"
81+ echo "OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
82+ echo "OPENAI_API_KEY first 10 chars: ${OPENAI_API_KEY:0:10}"
83+ echo "OPENAI_API_KEY last 5 chars: ${OPENAI_API_KEY: -5}"
84+ printenv | grep OPENAI || echo "No OPENAI env vars found"
85+
86+ - name : Debug Python Environment Variables
87+ run : |
88+ python -c "
89+ import os
90+ print('🐍 Python Environment Variable Check:')
91+ api_key = os.environ.get('OPENAI_API_KEY', 'NOT_SET')
92+ if api_key != 'NOT_SET':
93+ print(f' ✅ OPENAI_API_KEY: {api_key[:7]}... (length: {len(api_key)})')
94+ else:
95+ print(' ❌ OPENAI_API_KEY: NOT_SET')
96+ print(f' 🌐 OPENAI_API_BASE: {os.environ.get(\"OPENAI_API_BASE\", \"NOT_SET\")}')
97+ print(f' 🤖 OPENAI_MODEL_NAME: {os.environ.get(\"OPENAI_MODEL_NAME\", \"NOT_SET\")}')
98+ print(f' 📋 All OPENAI env vars:')
99+ for key, value in os.environ.items():
100+ if key.startswith('OPENAI'):
101+ print(f' {key}: {value[:10] if len(value) > 10 else value}...')
102+ "
103+
104+ - name : Validate API Key
105+ run : |
106+ echo "🔑 Testing API key validity with minimal OpenAI call..."
107+ python -c "
108+ import os
109+ try:
110+ from openai import OpenAI
111+ client = OpenAI(api_key=os.environ.get('OPENAI_API_KEY'))
112+ response = client.models.list()
113+ print('✅ API Key is VALID - OpenAI responded successfully')
114+ print(f'📊 Available models: {len(list(response.data))} models found')
115+ except Exception as e:
116+ print(f'❌ API Key is INVALID - Error: {e}')
117+ print('🔍 This explains why all API-dependent tests are failing')
118+ print('💡 The GitHub secret OPENAI_API_KEY needs to be updated with a valid key')
119+ "
120+ continue-on-error : true
121+
122+ - name : Debug PraisonAI API Key Usage
123+ env :
124+ OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}
125+ OPENAI_API_BASE : ${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}
126+ OPENAI_MODEL_NAME : ${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}
127+ LOGLEVEL : DEBUG
128+ run : |
129+ echo "🔍 Testing PraisonAI API key usage directly..."
130+ cd src/praisonai
131+ python -c "
132+ import os
133+ import sys
134+ sys.path.insert(0, '.')
135+
136+ print('🔧 Direct PraisonAI API Key Check:')
137+ print(f'Environment OPENAI_API_KEY: {os.environ.get(\"OPENAI_API_KEY\", \"NOT_SET\")[:10]}...')
138+
139+ # Test PraisonAI initialization
140+ from praisonai import PraisonAI
141+ praisonai = PraisonAI()
142+
143+ print(f'PraisonAI config_list: {praisonai.config_list}')
144+ api_key_from_config = praisonai.config_list[0].get('api_key', 'NOT_SET')
145+ print(f'API key from PraisonAI config: {api_key_from_config[:10] if api_key_from_config != \"NOT_SET\" else \"NOT_SET\"}...')
146+
147+ # Test PraisonAIModel with explicit API key (the way CrewAI will use it)
148+ from praisonai.inc.models import PraisonAIModel
149+
150+ print('\\n🧪 Testing PraisonAIModel with explicit API key (CrewAI method):')
151+ model_with_explicit_key = PraisonAIModel(
152+ model='openai/gpt-4o-mini',
153+ base_url=praisonai.config_list[0].get('base_url'),
154+ api_key=praisonai.config_list[0].get('api_key')
155+ )
156+ print(f' Model: {model_with_explicit_key.model}')
157+ print(f' Model name: {model_with_explicit_key.model_name}')
158+ print(f' API key var: {model_with_explicit_key.api_key_var}')
159+ print(f' API key (explicit): {model_with_explicit_key.api_key[:10] if model_with_explicit_key.api_key != \"nokey\" else \"NOT_SET\"}...')
160+ print(f' Base URL: {model_with_explicit_key.base_url}')
161+
162+ # Test if the model can be created without errors
163+ try:
164+ llm_instance = model_with_explicit_key.get_model()
165+ print(f' ✅ LLM instance created successfully: {type(llm_instance).__name__}')
166+ print(f' LLM instance API key: {getattr(llm_instance, \"openai_api_key\", \"NOT_FOUND\")[:10] if hasattr(llm_instance, \"openai_api_key\") else \"NO_API_KEY_ATTR\"}...')
167+ except Exception as e:
168+ print(f' ❌ Failed to create LLM instance: {e}')
169+ "
170+ continue-on-error : true
43171
44172 - name : Run Unit Tests
45173 run : |
@@ -49,20 +177,63 @@ jobs:
49177 run : |
50178 cd src/praisonai && python -m pytest tests/integration/ -v --tb=short --disable-warnings
51179
52- - name : Run AutoGen Framework Tests
180+ - name : Debug Directory Structure
181+ run : |
182+ echo "🔍 Debugging directory structure for CrewAI tests..."
183+ cd src/praisonai
184+ echo "Current working directory: $(pwd)"
185+ echo "📁 Contents of current directory:"
186+ ls -la
187+ echo ""
188+ echo "📁 Contents of tests directory:"
189+ ls -la tests/ || echo "❌ tests/ directory not found"
190+ echo ""
191+ echo "📁 Contents of tests/integration:"
192+ ls -la tests/integration/ || echo "❌ tests/integration/ directory not found"
193+ echo ""
194+ echo "📁 Looking for crewai directory:"
195+ find . -name "crewai" -type d 2>/dev/null || echo "❌ No crewai directories found"
196+ echo ""
197+ echo "📁 Full directory tree of tests:"
198+ tree tests/ || find tests/ -type d 2>/dev/null || echo "❌ Cannot explore tests directory"
199+
200+ - name : Test AutoGen Framework
53201 run : |
54202 echo "🤖 Testing AutoGen Framework Integration..."
55- cd src/praisonai && python tests/test_runner.py --pattern autogen --verbose || echo "⚠️ AutoGen tests completed with issues"
56- continue-on-error : true
203+ cd src/praisonai && python tests/test_runner.py --pattern autogen --verbose
57204
58- - name : Run CrewAI Framework Tests
205+ - name : Test CrewAI Framework
59206 run : |
60207 echo "⛵ Testing CrewAI Framework Integration..."
61- cd src/praisonai && python tests/test_runner.py --pattern crewai --verbose || echo "⚠️ CrewAI tests completed with issues"
62- continue-on-error : true
208+ cd src/praisonai
209+ echo "🔍 Trying test runner first..."
210+ python tests/test_runner.py --pattern crewai --verbose || {
211+ echo "❌ Test runner failed, trying direct pytest..."
212+ echo "📁 Current directory: $(pwd)"
213+ echo "📁 Looking for CrewAI tests..."
214+ find . -name "*crewai*" -type f 2>/dev/null
215+ echo "🧪 Trying direct pytest on integration/crewai..."
216+ python -m pytest tests/integration/crewai/ -v --tb=short --disable-warnings || {
217+ echo "❌ Direct path failed, trying relative path..."
218+ python -m pytest integration/crewai/ -v --tb=short --disable-warnings || {
219+ echo "❌ All CrewAI test attempts failed"
220+ exit 1
221+ }
222+ }
223+ }
63224
64- - name : Run Legacy Tests
225+ - name : Run Legacy Tests with API Key
226+ env :
227+ OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-github-actions-testing-only-not-real' }}
228+ OPENAI_API_BASE : ${{ secrets.OPENAI_API_BASE || 'https://api.openai.com/v1' }}
229+ OPENAI_MODEL_NAME : ${{ secrets.OPENAI_MODEL_NAME || 'gpt-4o-mini' }}
230+ LOGLEVEL : DEBUG
65231 run : |
232+ echo "🧪 Running legacy tests with real API key..."
233+ echo "🔧 Final environment check before pytest:"
234+ echo " OPENAI_API_KEY set: $([ -n "$OPENAI_API_KEY" ] && echo 'YES' || echo 'NO')"
235+ echo " OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
236+ echo " OPENAI_API_KEY starts with sk-: $(echo "$OPENAI_API_KEY" | grep -q '^sk-' && echo 'YES' || echo 'NO')"
66237 cd src/praisonai && python -m pytest tests/test.py -v --tb=short --disable-warnings
67238
68239 - name : Upload Coverage Reports
0 commit comments