Skip to content

MPP Coding Agent Integration #19

MPP Coding Agent Integration

MPP Coding Agent Integration #19

name: MPP Coding Agent Integration
on:
push:
branches: [ main, develop ]
paths:
- 'mpp-core/**'
- 'mpp-ui/**'
- '.github/workflows/integration-tests.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'mpp-core/**'
- 'mpp-ui/**'
schedule:
# Run integration tests daily at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
test_category:
description: 'Test category to run'
required: false
default: 'all'
type: choice
options:
- all
- simple
- business
- errors
- performance
- custom
pass_threshold:
description: 'Pass rate threshold (0-100%)'
required: false
default: '80'
type: string
keep_test_projects:
description: 'Keep test projects for debugging'
required: false
default: false
type: boolean
jobs:
integration-tests:
runs-on: ubuntu-latest
timeout-minutes: 60 # 增加超时时间以适应新的测试框架
strategy:
matrix:
node-version: [21.x] # 简化为单一版本以减少 CI 时间
test-category:
- ${{ github.event.inputs.test_category || 'all' }}
fail-fast: false
env:
# 配置 DeepSeek API
DEEPSEEK_TOKEN: ${{ secrets.DEEPSEEK_TOKEN }}
# 测试框架配置
CI: true
NODE_ENV: test
DEBUG: false
KEEP_TEST_PROJECTS: ${{ github.event.inputs.keep_test_projects || 'false' }}
PASS_THRESHOLD: ${{ github.event.inputs.pass_threshold || '80' }}
# 增加超时时间
TEST_TIMEOUT: 1200000 # 20分钟
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: mpp-ui/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('mpp-ui/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Workaround for git:// protocol in treesitter dependencies
run: |
echo "📦 Pre-creating build/js directory with cached yarn.lock"
mkdir -p build/js
if [ -f kotlin-js-store/yarn.lock ]; then
cp kotlin-js-store/yarn.lock build/js/yarn.lock
echo "✅ Copied pre-cached yarn.lock from kotlin-js-store"
else
echo "⚠️ No pre-cached yarn.lock found, will proceed without it"
fi
# Configure git to use https:// instead of git://
git config --global url."https://github.com/".insteadOf git://github.com/
echo "✅ Configured git to rewrite git:// URLs to https://"
- name: Install mpp-ui dependencies
working-directory: mpp-ui
run: npm install
- name: Build mpp-core
run: ./gradlew :mpp-core:assembleJsPackage
- name: Build mpp-ui
working-directory: mpp-ui
run: npm run build:ts
- name: Create test results directory
run: mkdir -p test-results
- name: Setup AutoDev config for CI
run: |
mkdir -p ~/.autodev
cat > ~/.autodev/config.yaml << EOF
active: ci-deepseek
configs:
- name: ci-deepseek
provider: deepseek
apiKey: ${{ secrets.DEEPSEEK_TOKEN }}
model: deepseek-chat
EOF
echo "✅ AutoDev config created for CI environment"
- name: Validate test framework
working-directory: mpp-ui
run: npm run test:framework
- name: Run integration tests v2
working-directory: mpp-ui
run: |
echo "🚀 Running CodingAgent Integration Tests v2"
echo "Category: ${{ matrix.test-category }}"
echo "Pass Threshold: ${PASS_THRESHOLD}%"
echo "Keep Test Projects: ${KEEP_TEST_PROJECTS}"
echo ""
npm run test:integration-v2
timeout-minutes: 45
- name: Analyze test results and check threshold
if: always()
working-directory: mpp-ui
env:
TEST_CATEGORY: ${{ matrix.test-category }}
run: |
echo "🎯 分析测试结果并检查阈值..."
# 运行测试结果分析脚本
node scripts/analyze-test-results.cjs
# 脚本会根据阈值检查结果设置适当的退出码
# 如果通过率低于阈值,脚本会以非零退出码退出
- name: Generate detailed test report
if: always()
working-directory: mpp-ui
run: |
echo "📊 Generating detailed test report..."
# 创建测试报告目录
mkdir -p test-results/reports
# 生成测试摘要
echo "## 🤖 CodingAgent Integration Tests v2 Report" > test-results/reports/summary.md
echo "" >> test-results/reports/summary.md
echo "- **Test Category**: ${{ matrix.test-category }}" >> test-results/reports/summary.md
echo "- **Node Version**: ${{ matrix.node-version }}" >> test-results/reports/summary.md
echo "- **Timestamp**: $(date)" >> test-results/reports/summary.md
echo "- **Pass Threshold**: ${PASS_THRESHOLD}%" >> test-results/reports/summary.md
echo "- **Status**: ${{ job.status }}" >> test-results/reports/summary.md
echo "" >> test-results/reports/summary.md
# 如果有测试结果文件,添加详细信息
if [ -d "test-results" ] && [ "$(find test-results -name '*.json' -o -name '*.xml' | head -1)" ]; then
echo "### 📈 Test Results Found" >> test-results/reports/summary.md
echo "Detailed test results are available in the artifacts." >> test-results/reports/summary.md
else
echo "### ⚠️ No detailed test results found" >> test-results/reports/summary.md
fi
echo "Test report generated successfully"
- name: Generate GitHub Actions summary
if: always()
env:
TEST_CATEGORY: ${{ matrix.test-category }}
NODE_VERSION: ${{ matrix.node-version }}
JOB_STATUS: ${{ job.status }}
run: |
echo "📊 生成 GitHub Actions 摘要..."
node .github/scripts/generate-test-summary.cjs
- name: Upload test results and reports
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-v2-${{ matrix.node-version }}-${{ matrix.test-category }}
path: |
mpp-ui/test-results/
mpp-ui/coverage/
retention-days: 14
- name: Upload test projects (for debugging)
uses: actions/upload-artifact@v4
if: failure() || env.KEEP_TEST_PROJECTS == 'true'
with:
name: test-projects-${{ matrix.node-version }}-${{ matrix.test-category }}
path: |
/tmp/agent-test-*
/tmp/autodev-test-*
retention-days: 7
- name: Comment PR with test results
uses: actions/github-script@v7
if: github.event_name == 'pull_request' && always()
with:
script: |
const fs = require('fs');
const path = require('path');
// 创建详细的测试结果评论
let comment = `## 🤖 CodingAgent Integration Tests v2 Results\n\n`;
comment += `### 📊 Test Configuration\n`;
comment += `- **Node.js Version:** ${{ matrix.node-version }}\n`;
comment += `- **Test Category:** ${{ matrix.test-category }}\n`;
comment += `- **Pass Threshold:** ${{ env.PASS_THRESHOLD }}%\n`;
comment += `- **Status:** ${{ job.status }}\n`;
comment += `- **Timestamp:** ${new Date().toISOString()}\n\n`;
// 读取测试报告摘要
try {
const summaryPath = 'mpp-ui/test-results/reports/summary.md';
if (fs.existsSync(summaryPath)) {
const summary = fs.readFileSync(summaryPath, 'utf8');
comment += `### 📈 Test Summary\n\n${summary}\n\n`;
}
} catch (error) {
console.log('Could not read test summary:', error.message);
}
if ('${{ job.status }}' === 'success') {
comment += `### ✅ Test Results\n\n`;
comment += `🎉 **All integration tests passed successfully!**\n\n`;
comment += `The CodingAgent demonstrates robust performance with:\n`;
comment += `- ✅ **Prompt Effectiveness**: System prompts correctly guide agent behavior\n`;
comment += `- ✅ **Tool Usage**: Accurate and efficient tool selection and usage\n`;
comment += `- ✅ **Code Quality**: Generated code meets quality standards\n`;
comment += `- ✅ **Task Completion**: All required functionality implemented\n\n`;
comment += `### 📊 Framework Features Validated\n`;
comment += `- 🎯 **Multi-dimensional Analysis**: Prompt effects, tool calls, code quality\n`;
comment += `- 📈 **Standardized Scoring**: Consistent evaluation metrics\n`;
comment += `- 🔧 **Detailed Reporting**: Comprehensive test insights\n`;
} else {
comment += `### ❌ Test Results\n\n`;
comment += `⚠️ **Some integration tests failed or encountered issues.**\n\n`;
comment += `**Next Steps:**\n`;
comment += `1. 📋 Check the detailed test logs in the Actions tab\n`;
comment += `2. 📁 Download test artifacts for detailed analysis\n`;
comment += `3. 🔍 Review specific test failures and error messages\n`;
comment += `4. 🛠️ Use the new test framework's detailed reports for debugging\n\n`;
comment += `**Available Artifacts:**\n`;
comment += `- \`test-results-v2-${{ matrix.node-version }}-${{ matrix.test-category }}\`: Detailed test results and reports\n`;
if ('${{ env.KEEP_TEST_PROJECTS }}' === 'true') {
comment += `- \`test-projects-${{ matrix.node-version }}-${{ matrix.test-category }}\`: Test project files for debugging\n`;
}
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
test-summary:
runs-on: ubuntu-latest
needs: integration-tests
if: always()
steps:
- name: Generate test summary
run: |
echo "# 🧪 CodingAgent Integration Test Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.integration-tests.result }}" = "success" ]; then
echo "✅ **All integration tests passed successfully!**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The CodingAgent demonstrates robust performance across all tested scenarios:" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Simple robustness tests" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Business scenario implementations" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Error recovery mechanisms" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Code quality standards" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Some integration tests failed**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Please review the test logs and artifacts for detailed information." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Common issues to check:" >> $GITHUB_STEP_SUMMARY
echo "- System resource constraints" >> $GITHUB_STEP_SUMMARY
echo "- Network connectivity issues" >> $GITHUB_STEP_SUMMARY
echo "- Environment configuration problems" >> $GITHUB_STEP_SUMMARY
echo "- CodingAgent system prompt effectiveness" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Test Categories" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Category | Description | Complexity |" >> $GITHUB_STEP_SUMMARY
echo "|----------|-------------|------------|" >> $GITHUB_STEP_SUMMARY
echo "| Simple | Basic tool usage validation | Low |" >> $GITHUB_STEP_SUMMARY
echo "| Video Support | BlogPost entity enhancement | Medium |" >> $GITHUB_STEP_SUMMARY
echo "| JWT Auth | Security implementation | High |" >> $GITHUB_STEP_SUMMARY
echo "| Spring Upgrade | Version upgrade with error handling | Very High |" >> $GITHUB_STEP_SUMMARY
echo "| GraphQL API | Modern API implementation | High |" >> $GITHUB_STEP_SUMMARY