Skip to content

Commit d4affc3

Browse files
authored
Workflows
1 parent 79ac7b8 commit d4affc3

2 files changed

Lines changed: 234 additions & 11 deletions

File tree

.github/workflows/enginescript-build-test.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,89 @@ jobs:
707707
EOF
708708
fi
709709
710+
- name: Create GitHub Annotations and Summary
711+
if: always()
712+
env:
713+
OVERALL_STATUS: ${{ steps.report-test-results.outputs.OVERALL_STATUS }}
714+
NGINX_STATUS: ${{ steps.report-test-results.outputs.NGINX_STATUS }}
715+
EVENT_NAME: ${{ github.event_name }}
716+
run: |
717+
echo "📝 Creating GitHub annotations and job summary..."
718+
719+
# Add test summary to job summary (already created in test-summary.md)
720+
if [ -f /tmp/ci-logs/test-summary.md ]; then
721+
cat /tmp/ci-logs/test-summary.md >> $GITHUB_STEP_SUMMARY
722+
fi
723+
724+
# Create GitHub annotations for build results
725+
echo "🔍 Creating annotations for build results..."
726+
727+
# Overall build status annotation
728+
if [ "$OVERALL_STATUS" = "✅ SUCCESS" ]; then
729+
echo "::notice title=Build Success::EngineScript Nginx build completed successfully for $EVENT_NAME event. All components built and configured correctly."
730+
else
731+
echo "::warning title=Build Failed::EngineScript Nginx build failed for $EVENT_NAME event. Check job summary for detailed error information."
732+
fi
733+
734+
# Component-specific annotations
735+
if [ "$NGINX_STATUS" = "✅ Success" ]; then
736+
echo "::notice title=Nginx Build Success::Nginx compiled and installed successfully with custom optimizations."
737+
else
738+
echo "::error title=Nginx Build Failed::Nginx build or installation failed. Review nginx.log for compilation errors."
739+
fi
740+
741+
# Check for specific issues in build logs and create targeted annotations
742+
if [ -f /tmp/ci-logs/nginx.log ]; then
743+
# Check for compilation errors
744+
if grep -qi "error:\|fatal error:\|compilation terminated" /tmp/ci-logs/nginx.log 2>/dev/null; then
745+
echo "::error title=Nginx Compilation Error::Nginx build encountered compilation errors. Check nginx.log for details."
746+
fi
747+
748+
# Check for missing dependencies
749+
if grep -qi "not found\|cannot find\|missing" /tmp/ci-logs/nginx.log 2>/dev/null; then
750+
echo "::warning title=Missing Dependencies::Nginx build detected missing dependencies. Review depends.log and nginx.log."
751+
fi
752+
753+
# Check for configuration issues
754+
if grep -qi "configuration error\|invalid configuration" /tmp/ci-logs/nginx.log 2>/dev/null; then
755+
echo "::error title=Nginx Configuration Error::Nginx configuration validation failed. Check nginx.conf syntax."
756+
fi
757+
fi
758+
759+
# Check setup log for system issues
760+
if [ -f /tmp/ci-logs/setup.log ]; then
761+
if grep -qi "error\|failed" /tmp/ci-logs/setup.log 2>/dev/null; then
762+
echo "::warning title=Setup Issues Detected::Base system setup encountered errors. Review setup.log for details."
763+
fi
764+
fi
765+
766+
# Check dependencies log for package issues
767+
if [ -f /tmp/ci-logs/depends.log ]; then
768+
if grep -qi "unable to install\|package.*not available\|failed to fetch" /tmp/ci-logs/depends.log 2>/dev/null; then
769+
echo "::error title=Dependency Installation Failed::Critical dependencies failed to install. Review depends.log."
770+
fi
771+
fi
772+
773+
# Disk space warnings
774+
AVAILABLE_SPACE=$(df -h / | tail -1 | awk '{print $4}')
775+
AVAILABLE_SPACE_NUM=$(df / | tail -1 | awk '{print $4}')
776+
if [ "$AVAILABLE_SPACE_NUM" -lt 1048576 ]; then # Less than 1GB
777+
echo "::warning title=Low Disk Space::Available disk space is low ($AVAILABLE_SPACE). This may affect build performance."
778+
fi
779+
780+
# Memory warnings
781+
AVAILABLE_MEM=$(free -m | grep '^Mem:' | awk '{print $7}')
782+
if [ "$AVAILABLE_MEM" -lt 512 ]; then # Less than 512MB
783+
echo "::warning title=Low Memory::Available memory is low (${AVAILABLE_MEM}MB). This may affect build performance."
784+
fi
785+
786+
# Summary annotation with actionable information
787+
if [ "$OVERALL_STATUS" = "✅ SUCCESS" ]; then
788+
echo "::notice title=Build Complete::All build steps completed successfully. Logs available in workflow artifacts for 7 days."
789+
else
790+
echo "::error title=Build Failed - Action Required::Build failed. Review error annotations above and check uploaded logs for detailed diagnostics."
791+
fi
792+
710793
- name: Create Issue Report for Failed Build
711794
if: failure() && steps.report-test-results.outputs.TEST_FAILED == 'true'
712795
uses: actions/github-script@v8

.github/workflows/gemini-code-assistant.yml

Lines changed: 151 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,70 @@ jobs:
163163
console.log('🤖 Initializing Gemini AI...');
164164
165165
const genAI = new GoogleGenerativeAI(apiKey);
166-
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
166+
167+
// Try different model names prioritizing quality first, then fallback on rate limits
168+
// Order: 2.5 models (highest quality) -> 2.0 models (higher RPM) -> legacy
169+
const modelNames = [
170+
"gemini-2.5-pro", // 5 RPM, 250K TPM - Highest quality
171+
"gemini-2.5-flash", // 10 RPM, 250K TPM - Best 2.5 balance
172+
"gemini-2.5-flash-preview", // 10 RPM, 250K TPM - Latest 2.5 features
173+
"gemini-2.5-flash-lite", // 15 RPM, 250K TPM - Faster 2.5
174+
"gemini-2.5-flash-lite-preview", // 15 RPM, 250K TPM - Latest 2.5 lite
175+
"gemini-2.0-flash", // 15 RPM, 1M TPM - Good 2.0 balance
176+
"gemini-2.0-flash-lite", // 30 RPM, 1M TPM - Highest RPM fallback
177+
"gemini-1.5-flash", // 15 RPM, 250K TPM - DEPRECATED fallback
178+
"gemini-pro" // Legacy final fallback
179+
];
180+
181+
let model = null;
182+
let modelUsed = null;
183+
184+
for (const modelName of modelNames) {
185+
try {
186+
console.log('🔧 Trying model:', modelName);
187+
model = genAI.getGenerativeModel({ model: modelName });
188+
189+
// Test the model with a small request to check availability/rate limits
190+
console.log('🧪 Testing model availability...');
191+
await model.generateContent("test");
192+
193+
modelUsed = modelName;
194+
console.log('✅ Successfully initialized and tested model:', modelName);
195+
break;
196+
} catch (modelError) {
197+
console.log('❌ Model', modelName, 'failed:', modelError.message);
198+
199+
// Check for rate limit errors specifically
200+
if (modelError.message && (
201+
modelError.message.includes('rate limit') ||
202+
modelError.message.includes('quota') ||
203+
modelError.message.includes('429') ||
204+
modelError.status === 429
205+
)) {
206+
console.log('⚠️ Rate limit detected, trying next model with higher RPM...');
207+
} else if (modelError.message && modelError.message.includes('404')) {
208+
console.log('⚠️ Model not found, trying next available model...');
209+
}
210+
continue;
211+
}
212+
}
213+
214+
if (!model) {
215+
throw new Error('No supported Gemini model could be initialized');
216+
}
167217
168218
const prompt = fs.readFileSync('analysis_prompt.txt', 'utf8');
169219
console.log('📝 Prompt loaded, size:', prompt.length, 'characters');
170220
171-
console.log('🚀 Generating analysis...');
221+
console.log('🚀 Generating analysis with model:', modelUsed);
172222
const result = await model.generateContent(prompt);
173223
const response = await result.response;
174224
const text = response.text();
175225
176226
fs.writeFileSync('ai_analysis_result.txt', text);
177227
console.log('✅ Analysis completed successfully');
178228
console.log('📄 Result size:', text.length, 'characters');
229+
console.log('🤖 Model used:', modelUsed);
179230
180231
} catch (error) {
181232
console.error('❌ Gemini analysis failed:', error.message);
@@ -241,14 +292,6 @@ jobs:
241292
echo "Provide specific, actionable feedback for server administration improvements." >> analysis_prompt.txt
242293
echo "" >> analysis_prompt.txt
243294
244-
# Add the actual code changes
245-
if [ "$CHANGES_AVAILABLE" = "true" ]; then
246-
echo "Here are the code changes to analyze:" >> analysis_prompt.txt
247-
echo "" >> analysis_prompt.txt
248-
cat code_changes.diff >> analysis_prompt.txt
249-
else
250-
echo "No code changes were detected in this commit." >> analysis_prompt.txt
251-
fi
252295
# Add the actual code changes
253296
if [ "$CHANGES_AVAILABLE" = "true" ]; then
254297
echo "Here are the code changes to analyze:" >> analysis_prompt.txt
@@ -290,4 +333,101 @@ jobs:
290333
fi
291334
292335
echo "============================================================"
293-
echo "✅ Analysis output complete"
336+
echo "✅ Analysis output complete"
337+
338+
- name: Create GitHub Annotations and Summary
339+
if: always()
340+
env:
341+
ANALYSIS_SUCCESS: ${{ steps.ai-analysis.outputs.analysis-success }}
342+
EVENT_NAME: ${{ github.event_name }}
343+
run: |
344+
echo "📝 Creating GitHub annotations and job summary..."
345+
346+
# Create job summary with analysis results
347+
echo "## 🤖 AI Code Analysis Results" >> $GITHUB_STEP_SUMMARY
348+
echo "" >> $GITHUB_STEP_SUMMARY
349+
echo "**Event:** $EVENT_NAME" >> $GITHUB_STEP_SUMMARY
350+
echo "**Status:** $([ "$ANALYSIS_SUCCESS" = "true" ] && echo "✅ Success" || echo "⚠️ Warning")" >> $GITHUB_STEP_SUMMARY
351+
echo "" >> $GITHUB_STEP_SUMMARY
352+
353+
if [ -f ai_analysis_result.txt ]; then
354+
# Add analysis results to job summary
355+
echo "### Analysis Details" >> $GITHUB_STEP_SUMMARY
356+
echo "" >> $GITHUB_STEP_SUMMARY
357+
echo '```' >> $GITHUB_STEP_SUMMARY
358+
cat ai_analysis_result.txt >> $GITHUB_STEP_SUMMARY
359+
echo '```' >> $GITHUB_STEP_SUMMARY
360+
361+
# Create GitHub annotations for key findings
362+
echo "🔍 Creating annotations for key findings..."
363+
364+
# Create notice annotation with summary
365+
echo "::notice title=AI Analysis Complete::EngineScript LEMP automation analysis completed for $EVENT_NAME event. Check job summary for detailed results."
366+
367+
# Parse analysis results for security issues and create annotations
368+
if grep -qi "security\|vulnerability\|exploit\|injection\|privilege escalation\|unsafe\|hardening" ai_analysis_result.txt 2>/dev/null; then
369+
echo "::warning title=Security Review Required::AI analysis detected potential security concerns in bash scripts or server configuration. Review analysis details in job summary."
370+
fi
371+
372+
# Check for bash scripting best practices
373+
if grep -qi "bash\|shell\|script\|quoting\|variable expansion\|error handling\|set -e" ai_analysis_result.txt 2>/dev/null; then
374+
echo "::notice title=Bash Scripting Standards::AI analysis found bash scripting recommendations. Check job summary for best practices."
375+
fi
376+
377+
# Check for nginx configuration issues
378+
if grep -qi "nginx\|configuration\|directive\|server block\|location block\|ssl\|tls" ai_analysis_result.txt 2>/dev/null; then
379+
echo "::notice title=Nginx Configuration::AI analysis found nginx configuration recommendations. Check job summary for details."
380+
fi
381+
382+
# Check for performance and optimization issues
383+
if grep -qi "performance\|optimization\|slow\|inefficient\|caching\|redis\|opcache" ai_analysis_result.txt 2>/dev/null; then
384+
echo "::notice title=Performance Optimization::AI analysis found LEMP stack performance optimization opportunities. Check job summary for details."
385+
fi
386+
387+
# Check for PHP configuration issues
388+
if grep -qi "php\|php-fpm\|php.ini\|memory_limit\|upload_max\|post_max" ai_analysis_result.txt 2>/dev/null; then
389+
echo "::notice title=PHP Configuration::AI analysis found PHP/PHP-FPM configuration recommendations. Check job summary for details."
390+
fi
391+
392+
# Check for MariaDB/MySQL issues
393+
if grep -qi "mariadb\|mysql\|database\|sql\|innodb\|query" ai_analysis_result.txt 2>/dev/null; then
394+
echo "::notice title=Database Configuration::AI analysis found MariaDB configuration recommendations. Check job summary for details."
395+
fi
396+
397+
# Check for Cloudflare integration issues
398+
if grep -qi "cloudflare\|cdn\|dns\|real.*ip\|proxy" ai_analysis_result.txt 2>/dev/null; then
399+
echo "::notice title=Cloudflare Integration::AI analysis found Cloudflare integration recommendations. Check job summary for details."
400+
fi
401+
402+
# Check for system administration best practices
403+
if grep -qi "systemd\|service\|permissions\|ownership\|chmod\|chown\|directory structure" ai_analysis_result.txt 2>/dev/null; then
404+
echo "::notice title=System Administration::AI analysis found system administration recommendations. Check job summary for details."
405+
fi
406+
407+
# Extract specific line-by-line feedback if available
408+
if grep -E "line [0-9]+|:[0-9]+:" ai_analysis_result.txt 2>/dev/null; then
409+
echo "::notice title=Line-Specific Feedback::AI analysis provided line-specific recommendations for bash scripts. See job summary for details."
410+
fi
411+
412+
# Check analysis length and create appropriate annotation
413+
ANALYSIS_SIZE=$(wc -c < ai_analysis_result.txt)
414+
if [ "$ANALYSIS_SIZE" -gt 1000 ]; then
415+
echo "::notice title=Detailed Analysis Available::Comprehensive AI analysis completed ($ANALYSIS_SIZE characters). Full results available in job summary."
416+
else
417+
echo "::notice title=Quick Analysis Complete::AI analysis completed with brief feedback. See job summary for details."
418+
fi
419+
420+
else
421+
echo "### ❌ Analysis Failed" >> $GITHUB_STEP_SUMMARY
422+
echo "" >> $GITHUB_STEP_SUMMARY
423+
echo "The AI analysis could not be completed. This may be due to:" >> $GITHUB_STEP_SUMMARY
424+
echo "- API configuration issues" >> $GITHUB_STEP_SUMMARY
425+
echo "- Network connectivity problems" >> $GITHUB_STEP_SUMMARY
426+
echo "- Service availability" >> $GITHUB_STEP_SUMMARY
427+
echo "" >> $GITHUB_STEP_SUMMARY
428+
echo "Please conduct manual code review." >> $GITHUB_STEP_SUMMARY
429+
430+
echo "::error title=AI Analysis Failed::Unable to complete automated analysis. Manual review required."
431+
fi
432+
433+
echo "✅ GitHub annotations and summary created successfully"

0 commit comments

Comments
 (0)