Implement RT-Thread 2025 Roadmap: Enhanced testing, automation, and B… #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | ||
| # Copyright (c) 2006-2025, RT-Thread Development Team | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Change Logs: | ||
| # Date Author Notes | ||
| # 2025-01-03 Copilot BSP analysis workflow for RT-Thread 2025 roadmap | ||
| # | ||
| name: BSP Analysis | ||
| # Controls when the action will run | ||
| on: | ||
| schedule: | ||
| - cron: '0 2 15 * *' | ||
| workflow_dispatch: | ||
| inputs: | ||
| detailed_report: | ||
| description: 'Generate detailed JSON report' | ||
| required: false | ||
| default: 'true' | ||
| type: boolean | ||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| jobs: | ||
| bsp_analysis: | ||
| runs-on: ubuntu-22.04 | ||
| name: BSP Slimming Analysis | ||
| if: github.repository_owner == 'RT-Thread' | ||
| steps: | ||
| - uses: actions/checkout@main | ||
| with: | ||
| fetch-depth: 1 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@main | ||
| with: | ||
| python-version: '3.9' | ||
| - name: Run BSP Analysis | ||
| run: | | ||
| cd tools/ci | ||
| python bsp_analysis.py --output bsp_analysis_report.json --top-duplicates 10 | ||
| - name: Upload Analysis Report | ||
| if: github.event.inputs.detailed_report == 'true' || github.event_name == 'schedule' | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: bsp-analysis-report | ||
| path: tools/ci/bsp_analysis_report.json | ||
| retention-days: 90 | ||
| - name: Create Issue Comment | ||
| if: github.event_name == 'schedule' | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| try { | ||
| const reportPath = 'tools/ci/bsp_analysis_report.json'; | ||
| const report = JSON.parse(fs.readFileSync(reportPath, 'utf8')); | ||
| const summary = report.summary; | ||
| const duplicates = report.duplicates; | ||
| const recommendations = report.recommendations; | ||
| const body = `## 📊 Monthly BSP Analysis Report | ||
| ### Summary Statistics | ||
| - **Total BSPs**: ${summary.total_bsps} | ||
| - **Total Files**: ${summary.total_files.toLocaleString()} | ||
| - **Total Size**: ${summary.total_size_mb.toFixed(1)} MB | ||
| - **Average Files per BSP**: ${summary.avg_files_per_bsp.toFixed(0)} | ||
| - **Average Size per BSP**: ${summary.avg_size_per_bsp_mb.toFixed(1)} MB | ||
| ### Duplicate File Analysis | ||
| - **Duplicate Groups**: ${duplicates.total_duplicate_groups} | ||
| - **Wasted Space**: ${(duplicates.total_wasted_space / (1024*1024)).toFixed(1)} MB | ||
| ### Recommendations | ||
| ${recommendations.map(rec => `- ${rec}`).join('\n')} | ||
| ### Top Duplicate Files | ||
| ${Object.entries(duplicates.duplicate_groups) | ||
| .sort((a, b) => b[1].wasted_space - a[1].wasted_space) | ||
| .slice(0, 5) | ||
| .map(([hash, info], index) => | ||
| \`\${index + 1}. **\${info.count} copies** - \${(info.wasted_space / 1024).toFixed(1)} KB wasted\` | ||
| ).join('\n')} | ||
| --- | ||
| *This automated analysis is part of the RT-Thread 2025 roadmap BSP slimming plan.* | ||
| *Report generated on: ${new Date().toISOString()}* | ||
| *For detailed analysis, check the workflow artifacts.*`; | ||
| await github.rest.issues.createComment({ | ||
| issue_number: 9822, | ||
| owner: 'RT-Thread', | ||
| repo: 'rt-thread', | ||
| body: body | ||
| }); | ||
| // Also create a separate issue if there are significant problems | ||
| if (duplicates.total_wasted_space > 50 * 1024 * 1024) { // >50MB wasted | ||
| const issueBody = `## 🚨 BSP Optimization Opportunity Detected | ||
| The monthly BSP analysis has detected significant optimization opportunities: | ||
| **Wasted Space**: ${(duplicates.total_wasted_space / (1024*1024)).toFixed(1)} MB from duplicate files | ||
| **Duplicate Groups**: ${duplicates.total_duplicate_groups} | ||
| This represents a significant opportunity for the BSP slimming plan in the RT-Thread 2025 roadmap. | ||
| ### Recommended Actions: | ||
| 1. Review the top duplicate files and consider creating shared libraries | ||
| 2. Consolidate common BSP components into the components/ directory | ||
| 3. Implement Kconfig templates for common configurations | ||
| 4. Remove or compress large unnecessary files | ||
| ### Related Issues: | ||
| - #9960 (BSP 瘦身计划) | ||
| - #9822 (RT-Thread 2025 Roadmap) | ||
| For detailed analysis, see the workflow artifacts at: | ||
| https://github.com/RT-Thread/rt-thread/actions | ||
| `; | ||
| await github.rest.issues.create({ | ||
| owner: 'RT-Thread', | ||
| repo: 'rt-thread', | ||
| title: `BSP Optimization Opportunity: ${(duplicates.total_wasted_space / (1024*1024)).toFixed(1)}MB Wasted Space Detected`, | ||
| body: issueBody, | ||
| labels: ['enhancement', 'BSP', '5.2.0'] | ||
| }); | ||
| } | ||
| } catch (error) { | ||
| console.log('Could not create issue comment:', error.message); | ||
| console.log('Error details:', error); | ||
| } | ||