-
Notifications
You must be signed in to change notification settings - Fork 5.4k
147 lines (120 loc) · 4.71 KB
/
Copy pathbsp_analysis.yml
File metadata and controls
147 lines (120 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#
# 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);
}