Skip to content

Commit b006e40

Browse files
committed
fix: Remove PR commenting from size analysis workflow
- Replace PR comments with workflow summary output - Add size analysis script for local development - Remove unnecessary PR write permissions - Add workflow failure on significant size increases - Provide fallback size analysis without external dependencies
1 parent 732d92a commit b006e40

File tree

2 files changed

+95
-6
lines changed

2 files changed

+95
-6
lines changed

.github/workflows/size-analysis.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
runs-on: ubuntu-22.04
1717

1818
permissions:
19-
pull-requests: write
2019
contents: read
2120

2221
steps:
@@ -91,11 +90,25 @@ jobs:
9190
head -20 target/pr-bloat-report.txt >> size_report.md 2>/dev/null || echo "No function data available" >> size_report.md
9291
echo '```' >> size_report.md
9392
94-
- name: Comment PR with size analysis
95-
uses: thollander/actions-comment-pull-request@v2
96-
with:
97-
filePath: size_report.md
98-
comment_tag: size-analysis
93+
- name: Output size analysis to workflow summary
94+
run: |
95+
echo "## 📊 Binary Size Analysis" >> $GITHUB_STEP_SUMMARY
96+
cat size_report.md >> $GITHUB_STEP_SUMMARY
97+
98+
- name: Output size analysis to console
99+
run: |
100+
echo "=== Binary Size Analysis ==="
101+
cat size_report.md
102+
103+
- name: Check for significant size increase
104+
run: |
105+
# Extract size difference from the report
106+
if grep -q "⚠️ Binary size increased by more than 10KB" size_report.md; then
107+
echo "::error::Binary size increased by more than 10KB! Please review."
108+
exit 1
109+
elif grep -q "🚨 Binary size increased significantly" size_report.md; then
110+
echo "::warning::Binary size increased significantly. Consider optimization."
111+
fi
99112
100113
- name: Upload detailed reports
101114
uses: actions/upload-artifact@v4

scripts/size-analysis.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
# Binary size analysis script for local development
3+
# Usage: ./scripts/size-analysis.sh [baseline-branch]
4+
5+
set -e
6+
7+
BASELINE_BRANCH=${1:-main}
8+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
9+
10+
echo "🔍 Analyzing binary size changes..."
11+
echo "Baseline: $BASELINE_BRANCH"
12+
echo "Current: $CURRENT_BRANCH"
13+
echo ""
14+
15+
# Function to build and analyze
16+
analyze_size() {
17+
local branch=$1
18+
local output_file=$2
19+
20+
echo "Building $branch..."
21+
git checkout $branch >/dev/null 2>&1
22+
cargo build --release --target thumbv7em-none-eabihf >/dev/null 2>&1
23+
24+
# Check if cargo bloat is available
25+
if command -v cargo-bloat >/dev/null 2>&1; then
26+
cargo bloat --release --target thumbv7em-none-eabihf -n 20 > $output_file 2>/dev/null || {
27+
echo "cargo bloat failed, using basic size info"
28+
ls -la target/thumbv7em-none-eabihf/release/aspeed-ddk > $output_file
29+
}
30+
else
31+
echo "cargo-bloat not found, install with: cargo install cargo-bloat"
32+
ls -la target/thumbv7em-none-eabihf/release/aspeed-ddk > $output_file
33+
fi
34+
}
35+
36+
# Store current branch
37+
ORIGINAL_BRANCH=$CURRENT_BRANCH
38+
39+
# Analyze baseline
40+
analyze_size $BASELINE_BRANCH target/baseline-size.txt
41+
42+
# Analyze current branch
43+
analyze_size $CURRENT_BRANCH target/current-size.txt
44+
45+
# Restore original branch
46+
git checkout $ORIGINAL_BRANCH >/dev/null 2>&1
47+
48+
echo "📊 Size Analysis Results:"
49+
echo "========================"
50+
51+
# Extract binary sizes if using cargo bloat
52+
if grep -q "File" target/baseline-size.txt 2>/dev/null; then
53+
BASELINE_SIZE=$(grep "File" target/baseline-size.txt | awk '{print $3}' | head -1)
54+
CURRENT_SIZE=$(grep "File" target/current-size.txt | awk '{print $3}' | head -1)
55+
56+
if [[ $BASELINE_SIZE =~ ([0-9.]+)([A-Za-z]+) ]]; then
57+
echo "Baseline size: $BASELINE_SIZE"
58+
fi
59+
if [[ $CURRENT_SIZE =~ ([0-9.]+)([A-Za-z]+) ]]; then
60+
echo "Current size: $CURRENT_SIZE"
61+
fi
62+
else
63+
# Fallback to file size
64+
BASELINE_BYTES=$(stat -c%s target/thumbv7em-none-eabihf/release/aspeed-ddk 2>/dev/null || echo "0")
65+
echo "Binary size: $BASELINE_BYTES bytes"
66+
fi
67+
68+
echo ""
69+
echo "Top functions in current build:"
70+
echo "==============================="
71+
head -20 target/current-size.txt
72+
73+
echo ""
74+
echo "Full reports saved in:"
75+
echo "- target/baseline-size.txt"
76+
echo "- target/current-size.txt"

0 commit comments

Comments
 (0)